import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    static class Node {
        int x;
        int y;
        public Node(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            int m = in.nextInt();
            int[][] arr = new int[n][m];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    arr[i][j] = in.nextInt();
                }
            }
            List<Node> list = new ArrayList<>();
            List<Node> minList = new ArrayList<>();
            boolean[][] isSame = new boolean[n][m];

            migong(list, minList, 0, 0, arr, isSame);
            for (Node node : minList) {
                System.out.println("("+node.x+","+node.y+")");
            }

        }
    }

    public static void migong(List<Node> list, List<Node> minList, int x,
    int y, int[][] arr, boolean[][] isSame) {
        if (x < 0 || x >= arr.length || y < 0 || y >= arr[0].length || 
        isSame[x][y] == true || arr[x][y] == 1) {
            return;
        }

        Node node = new Node(x, y);
        list.add(node);
        isSame[x][y] = true;
        if (x == arr.length-1 && y == arr[0].length-1) {
            if (minList.isEmpty() || minList.size() > list.size()) {
                minList.addAll(list);
            }
            list.remove(list.size()-1);
            isSame[x][y] = false;
            return;
        }
        migong(list, minList, x+1, y, arr, isSame);
        migong(list, minList, x-1, y, arr, isSame);
        migong(list, minList, x, y+1, arr, isSame);
        migong(list, minList, x, y-1, arr, isSame);
        list.remove(list.size()-1);
        isSame[x][y] = false;
    }
}