while True: try: m,n = map(int,input().split()) matrix = [] for i in range(m): d = list(map(int,input().split())) #print(c) matrix.append(d) def dfs(path): if path[-1] == [m-1,n-1]: return path r, c = path[-1] matrix[r][c] = 2 directions = [[r+1,c],[r,c+1],[r-1,c],[r,c-1]] for i,j in directions: if ...