#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int row = 0, col = 0;
vector<vector<int> > vec;
vector<pair<int, int> > ans;
vector<pair<int, int> > temp;
void dfs(int a, int b)
{
temp.push_back({a, b});
vec[a][b] = 1;
if(a == row - 1 && b == col - 1)
{
ans = temp;
return ;
}
if(a - 1 >= 0 && vec[a - 1][b] == 0 ) dfs(a - 1, b);//上
if(a + 1 <= row - 1 && vec[a + 1][b] == 0 ) dfs(a + 1, b);//下
if(b - 1 >= 0 && vec[a][b - 1] == 0 ) dfs(a, b - 1);//左
if(b + 1 <= col - 1 && vec[a][b + 1] == 0 ) dfs(a, b + 1);//右
vec[a][b] = 0;
temp.pop_back();
}
int main(int argc, char* argv[])
{
while(cin >> row >> col)
{
for(int i = 0; i < row; ++i)
{
vector<int> temp;
for(int j = 0; j < col; ++j)
{
int val = 0;
cin >> val;
temp.push_back(val);
}
vec.push_back(temp);
}
dfs(0, 0);
for(auto c : ans)
{
cout << "(" << c.first << "," << c.second << ")" << endl;
}
vec.clear();
ans.clear();
temp.clear();
}
return 0;
}