#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n;
string s[10];
bool v[10][100005];
pair<ll,ll>p[10][100005];
void f(ll r,ll c)
{
if(c==n-1)
{
vector<pair<ll,ll>>h;
while(c>0)
{
pair<ll,ll>prev=p[r][c];
if(r<prev.first||(r==0&&prev.first==0))
{
if(!h.empty()&&h.back().first+h.back().second==c)
{
h.back().second++;
}
else
{
h.push_back({c-1,1});
}
}
r=prev.first;
c=prev.second;
}
reverse(h.begin(),h.end());
cout<<h.size()<<endl;
for(auto i:h)
{
cout<<i.first<<" "<<i.second<<endl;
}
exit(0);
}
v[r][c]=1;
ll nr,nc;
nc=c+1;
nr=max(0LL,r-1);
if(!v[nr][nc]&&s[nr][nc]=='.')
{
p[nr][nc]={r,c};
f(nr,nc);
}
nr=min(9LL,r+1);
if(!v[nr][nc]&&s[nr][nc]=='.')
{
p[nr][nc]={r,c};
f(nr,nc);
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n;
for(ll i=0;i<10;i++)
{
cin>>s[i];
}
if(s[9][0]=='X')
{
return 0;
}
f(9,0);
return 0;
}