while True: try: m, n = map(int, (input().split())) grid = [] for _ in range(m): line = list(map(int, input().split())) grid.append(line) except: break else: def findPath(grid, i, j, path): if not 0 <= i < m or not 0 <= j < n or grid[i][j] == 1: return grid[i][j] = 1 path.append((i, j)) if i == m - 1 and j == n - 1: for cor in path: print('({0},{1})'.format(cor[0], cor[1])) return else: findPath(grid, i - 1, j, path) findPath(grid, i + 1, j, path) findPath(grid, i, j - 1, path) findPath(grid, i, j + 1, path) path.pop() findPath(grid, 0, 0, [])