deals = [
        lambda x, y: [x + 1, y],  # 向下
        lambda x, y: [x, y + 1],  # 向右
        lambda x, y: [x - 1, y],  # 向上
        lambda x, y: [x, y - 1],  # 向左
    ]
    path = [start]  # 已走路径
    maze[0][0] = 2  # 走过的坐标标记为2
    while len(path) > 0:
        cur_node = path[-1]
        if cur_node == end:
            break
        for deal in deals:
            next_node = deal(cur_node[0], cur_node[1])
            if 0 <= next_node[0] <= end[0] and 0 <= next_node[1] <= end[1]:
                if maze[next_node[0]][next_node[1]] == 0:  # 可以走的坐标
                    path.append(next_node)  # 添加到已走路径
                    maze[next_node[0]][next_node[1]] = 2  # 走过的坐标标记为2
                    break
        else:
            path.pop()
    return path


while True:
    try:
        n, m = map(int, input().split())
        ipt_maze = []
        for i in range(n):
            ipt_maze.append(list(map(int, input().split())))
        final_path = deal_maze([0, 0], [n - 1, m - 1], ipt_maze)
        for i in final_path:
            print(f"({i[0]},{i[1]})")
    except:
        break