#include <iostream>
#include <queue>
#include <string>
#include <vector>
using namespace std;
struct node
{
int x,y;
int step;
vector <int> qx;
vector <int> qy;
};
int n,m;
int sx,sy;
int gx,gy;
node ans;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
bool vis[600][600];
queue <node> q;
void bfs()
{
while(!q.empty())
{
node now = q.front();
q.pop();
if(now.x == gx && now.y == gy)
{
ans = now;
return;
}
for(int i=0;i<4;i++)
{
int xx = dx[i] + now.x;
int yy = dy[i] + now.y;
if(xx >= 1 && xx <= n && yy >= 1 && yy <= m && vis[xx][yy] == true)
{
node tool;
tool.x = xx;
tool.y = yy;
tool.step = now.step+1;
tool.qx.push_back(xx);
tool.qy.push_back(yy);
vis[xx][yy] = false;
q.push(tool);
}
}
}
return ;
}
int main()
{
cin >> n >> m;
sx = sy = 1;
gx = n;gy = m;
for(int i=1;i<=n;i++)
{
string s;
cin >> s;
for(int j=0;j<s.size();j++)
{
if(s[j]=='.')
vis[i][j+1] = true;
else
vis[i][j+1] = false;
}
}
node tool;
tool.x = sx;
tool.y = sy;
q.push(tool);
bfs();
for(vector<int>::iterator it=ans.qx.begin();it<ans.qx.end();it+=2)
{
cout<<ans.qx[it-ans.qx.begin()]<<' '<<ans.qy[it-ans.qx.begin()]<<endl;
}
return 0;
}