global_rout = []
m,n = input().split()
m,n = int(m),int(n)
mapp = []
for i in range(m) :
mapp.append(list(map(int,input().split())))
# print(mapp)
def print_route(route):
for r in route:
print(f"({r[0]},{r[1]})")
def dfs_fun(rout,x,y):
if -1<x<m and -1<y<n and mapp[x][y] == 0 and ([x,y] not in rout):
rout = rout + [[x,y]]
if x == m-1 and y == n-1:
global_rout.append(rout)
dfs_fun(rout,x+1,y)
dfs_fun(rout,x,y+1)
dfs_fun(rout,x-1,y)
dfs_fun(rout,x,y-1)
dfs_fun([[0,0]],1,0)
dfs_fun([[0,0]],0,1)
# print(len(global_rout))
if len(global_rout) > 0:
print_route(global_rout[-1])