Advertisement
Aikiro42

Untitled

Jan 26th, 2020
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. T = int(input())
  2.  
  3. solved_grids = []
  4.  
  5. i = 0
  6. while i < T:
  7. r, c, M, N = map(int, input().split())
  8. G = [input().split(" ") for _ in range(r)]
  9.  
  10. for x in range(len(G)):
  11. G[x] = G[-(M % c):] + G[:-(M % c)]
  12.  
  13. G = G[(N % r):] + G[:(N % r)]
  14.  
  15. solved_grids.append(G)
  16. i += 1
  17.  
  18. for grid in solved_grids:
  19. for row in grid:
  20. print(' '.join(row))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement