#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
//英语 抄博友程序 模拟
string p;
char da[10][10];
int hang[10];
int lie[10];
vector<string> jg;
void find(int x,int y,int dx,int dy,int step)
{
//cout<<x<<" "<<y<<" "<<dx<<" "<<dy<<" "<<step<<endl;
for(int i=x+dx,j=y+dy,js=1;js!=step;i=i+dx,j=j+dy,js++)
{
if(i>=0 && i<8 && j>=0 && j<8)
{
if(da[i][j]!=p[0]&&da[i][j]!='.')
{
//cout<<"fh0"<<endl;
return;
}
}else
{
//cout<<"fh1"<<endl;
return;
}
}
if((x+step*dx)>=0 && (x+step*dx)<8 &&(y+step*dy)>=0&& (y+step*dy)<8&&da[x+step*dx][y+step*dy]!=p[0])
{
//cout<<"hi"<<endl;
string fh="";
fh=fh+(char)(x+'A');
fh=fh+(char)(y+'1');
fh=fh+'-';
fh=fh+(char)(x+step*dx+'A');
fh=fh+(char)(y+step*dy+'1');
//cout<<fh<<endl;
jg.push_back(fh);
}
}
int main()
{
while(1)
{
memset(hang,0,sizeof(hang));
memset(lie,0,sizeof(lie));
jg.clear();
for(int i=0;i<8;i++)
{
for(int j=0;j<8;j++)
{
cin>>da[i][j];
if(cin.eof()==1)
{
return 0;
}
if(da[i][j]!='.')
{
hang[i]++;
lie[j]++;
}
}
}
/*
for(int i=0;i<8;i++)
{
for(int j=0;j<8;j++)
{
cout<<da[i][j];
}
cout<<endl;
}*/
cin>>p;
//cout<<p<<endl;
for(int i=0;i<8;i++)
{
for(int j=0;j<8;j++)
{
if(da[i][j]==p[0])
{
find(i,j,1,0,lie[j]);
find(i,j,-1,0,lie[j]);
find(i,j,0,1,hang[i]);
find(i,j,0,-1,hang[i]);
int js=1;
for(int ti=i+1,tj=j+1;ti<8&&tj<8;ti++,tj++)
{
if(da[ti][tj]!='.')
{
js++;
}
}
//cout<<js<<endl;
for(int ti=i-1,tj=j-1;ti>=0&&tj>=0;ti--,tj--)
{
if(da[ti][tj]!='.')
{
js++;
}
}
//cout<<js<<endl;
find(i,j,1,1,js);
find(i,j,-1,-1,js);
js=1;
for(int ti=i+1,tj=j-1;ti<8&&tj>=0;ti++,tj--)
{
if(da[ti][tj]!='.')
{
js++;
}
}
for(int ti=i-1,tj=j+1;ti>=0&&tj<8;ti--,tj++)
{
if(da[ti][tj]!='.')
{
js++;
}
}
find(i,j,1,-1,js);
find(i,j,-1,1,js);
}
}
}
if(jg.size()==0)
{
cout<<"No moves are possible"<<endl<<endl;
}else
{
sort(jg.begin(),jg.end());
for(int i=0;i<jg.size();i++)
{
cout<<jg[i]<<endl;
}
cout<<endl;
}
}
return 0;
}