#5#6#7#8#9 TLE
#10 RE已改
#include <bits/stdc++.h>
using namespace std;
struct node{
int x,y;
int from;
int step;
}lst[226];
int n,m;
char a[16][16];
bool vis[16][16];
int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};
void out (int z)
{
if(lst[z].from!=-1)
{
out(lst[z].from);
}
cout << lst[z].x << " " << lst[z].y << endl;
}
void bfs()
{
int cl=1,op=1;
lst[cl].x=1;
lst[cl].y=1;
lst[cl].from=-1;
lst[cl].step=1;
vis[1][1]=true;
while(cl<=op)
{
for(int i=0;i<4;i++)
{
int tx=lst[cl].x+dx[i];
int ty=lst[cl].y+dy[i];
if(tx>=1&&tx<=n&&ty>=1&&ty<=m&&!vis[tx][ty]&&a[tx][ty]=='.')
{
++op;
lst[op].x=tx;
lst[op].y=ty;
lst[op].from=cl;
lst[op].step=lst[cl].step+1;
vis[tx][ty]=true;
if(tx==n&&ty==m)
{
out(op);
exit(0);
}
}
}
cl++;
}
}
int main()
{
cin >> n >> m;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
cin >> a[i][j];
}
}
bfs();
cout << "Noway!" << endl;
return 0;
}