let maze;
let line;
let n, m;
while ((line = readline())) {
  let str;
  [n, m] = line.split(" ").map(Number);
  maze = [];
  while ((str = readline())) {
    maze.push(str.split(" ").map(Number));
  }
  find(0, 0, []);
}

function find(i, j, road) {
  road.push([i, j]);
  maze[i][j] = 1;
  if (i == n - 1 && j == m - 1) {
    for (let [a, b] of road) {
      print(`(${a},${b})`);
    }
  }

  if (j + 1 < m && maze[i][j + 1] == 0)
    find(i, j + 1, JSON.parse(JSON.stringify(road)));
  if (i + 1 < n && maze[i + 1][j] == 0)
    find(i + 1, j, JSON.parse(JSON.stringify(road)));
  if (j - 1 >= 0 && maze[i][j - 1] == 0)
    find(i, j - 1, JSON.parse(JSON.stringify(road)));
  if (i - 1 >= 0 && maze[i - 1][j] == 0)
    find(i - 1, j, JSON.parse(JSON.stringify(road)));

  maze[i][j] = 0;
}