/*
本宝的程序外人别想看！！

name: [夏宝宝]
run time：[] ms
compilation time: [] ms
output memory: [] MiB
where: []
state: []
*/
#include<bits/stdc++.h>
using namespace std;

int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, m, b, e;
	
	cin>>n>>m;
	
	int ga[n+1][m+1]={0};
	
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=n; j++)
		{
			string tmp;
			
			cin>>tmp; 
			
			if(tmp=='.')
			{
				ga[i][j]=1;
				ga[j][i]=1;
			}
		}
	}
	
	int dist[n][m]={0xffffff};
	
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		{
			if(ga[i][j]=1)
			{
				dist[i][j]=0;
			}
		}
	}
	
	int ans1=0, ans2=0, ans3=0;
	
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=m; j++)
		{
			queue<int> q;
			bool inque[n+1]={false};
			
			q.push(n);
			inque[1]=true;
			int b=0;
			
			while(!q.empty())
			{
				int h=q.front();
				q.pop();
				b++;
				
				if(h==m && h>ans3)
				{
					ans3=h;
					ans1=i;
					ans2=j;
				}
				
				cout<<h<<' ';
				
				for(int i=1; i<=n; i++)
				{
					if(ga[h][i] && inque[i]==false)
					{
						q.push(i);
						inque[i]=true;
					}
				}
			}
		}
	}
	
	cout<<ans1<<' '<<ans2<<endl;
	
	return 0;
}