import java.util.*;

public class Main {
    static List<int[]> path = new ArrayList<>();
    static boolean found = false;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] maze = new int[h][w];

        // 读入迷宫
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                maze[i][j] = sc.nextInt();
            }
        }

        dfs(maze, h, w, 0, 0);

        // 输出路径
        for (int[] p : path) {
            System.out.println("(" + p[0] + "," + p[1] + ")");
        }
    }

    private static void dfs(int[][] maze, int h, int w, int x, int y) {
        // 越界、遇墙、已经找到路径,则停止
        if (x < 0 || x >= h || y < 0 || y >= w || maze[x][y] != 0 || found) {
            return;
        }

        // 添加当前坐标到路径中
        path.add(new int[]{x, y});

        // 到达终点,标记成功,返回
        if (x == h - 1 && y == w - 1) {
            found = true;
            return;
        }

        // 标记已访问
        maze[x][y] = 2;

        // 尝试四个方向
        dfs(maze, h, w, x + 1, y); // 下
        dfs(maze, h, w, x - 1, y); // 上
        dfs(maze, h, w, x, y + 1); // 右
        dfs(maze, h, w, x, y - 1); // 左

        // 如果没找到,撤回上一步(回溯)
        if (!found) {
            maze[x][y] = 0;
            path.remove(path.size() - 1);
        }
    }
}