물고기 움직이고 상어 움직이면 된다. import sys input = sys.stdin.readline def move_fish(arr): ret = [[[] for _ in range(4)] for _ in range(4)] for x in range(4): for y in range(4): while arr[x][y]: d = arr[x][y].pop() for i in range(d, d - 8, -1): i %= 8 nx, ny = x + delta[i][0], y + delta[i][1] if (nx, ny) != shark and 0