def dfs(i, j):
    walk = [(0,1), (0,-1), (1,0), (-1,0)]
    
    if i == m-1 and j == n-1:
        for p in path:
            print("({x},{y})".format(x=p[0], y=p[1]))
        return
    
    for w in walk:
        x = i + w[0]
        y = j + w[1]
        if 0 <= x < m and 0 <= y < n and lst[x][y] == 0:
            lst[x][y] = 1
            path.append((x,y))
            dfs(x,y)
            lst[x][y] == 0
            path.pop()   

while 1:
    try:
        lst = []
        m, n = list(map(int, input().split()))
        for _ in range(m):
           lst.append(list(map(int, input().split()))) 
        
        path = [(0,0)]
        lst[0][0] = 1
        
        dfs(0,0)
                            
    except:
        break