import java.io.*;
import java.util.*;

class Point{
    int x;
    int y;

    Point(int x,int y){
        this.x = x;
        this.y = y;
    }
}

public class Main{
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()){
            int n = sc.nextInt();
            int m = sc.nextInt();
            int[][] num = new int[n][m];
            for(int i = 0; i < n; ++i){
                for(int j = 0; j < m; ++j){
                    num[i][j] = sc.nextInt(); 
                }
            }
            List<List<Point>> res = new ArrayList<>();
            dfs(num, 0, 0, n - 1, m - 1, new ArrayList<Point>(), res);
            int minSize = Integer.MAX_VALUE;
            int minIndex = 0;
            for(int i = 0; i < res.size(); ++i){
                if(minSize > res.get(i).si***Size = res.get(i).si***Index = i;
                }
            }
            for(Point p : res.get(minIndex)){
                System.out.println("("+ p.x + "," + p.y + ")");
            }
        }

    }
    public static void dfs(int[][] num, int i, int j, int n, int m, List<Point> list, List<List<Point>> res){
        if(i == n && j == m){
            // 走到尾部,添加节点
            list.add(new Point(i, j));
            // 添加到res中
            res.add(new ArrayList<>(list));
            return;
        }
        // 添加当前元素
        list.add(new Point(i,j));
        if((i + 1) <= n && j <= m && num[i + 1][j] == 0){
            // 移除添加到最后的一个元素
            dfs(num, i + 1, j, n, m, list, res);
            list.remove(list.size() - 1);
        }
        if(i <= n && (j + 1) <= m && num[i][j + 1] == 0){
            dfs(num, i, j + 1, n, m, list, res);
            list.remove(list.size() - 1);
        }
    }
}