n,m = list(map(int, input().strip().split(" "))) qipan = [] for _ in range(n): qipan.append(list(input().strip())) x,y = list(map(int, input().strip().split(" "))) res = 0 def move(qipan, x, y, tmp=None): global res if x < 0 or x > n or y < 0 or y > m: ...