#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;
char board[8][8];
struct IDX{
int i,j;
};
bool isCheck_knight(int I,int J,int color)
{
int dx[8]={1,1,-1,-1,2,2,-2,-2};
int dy[8]={2,-2,2,-2,1,-1,1,-1};
int a,b;
for(int i=0;i<8;i++)
{
a=dx[i]+I;
b=dy[i]+J;
if(a>=0 && a<8 && b>=0 && b<8)
{
if(board[a][b]=='N' && color==0)
return 1;
else if(board[a][b]=='n' && color==1)
return 1;
}
}
return 0;
}
bool ischeck_king(int I,int J,int color)
{
int dx[8]={1,1,-1,-1,0,0,1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
int a,b;
for(int i=0;i<8;i++)
{
a=dx[i]+I;
b=dy[i]+J;
if(a>=0 && a<8 && b>=0 && b<8)
{
if(board[a][b]=='K' && color==0)
return 1;
else if(board[a][b]=='k' && color==1)
return 1;
}
}
return 0;
}
bool ischeck_bishop(int I,int J,int color)
{
int a=I,b=J;
char ch;
if(color)
ch='b';
else
ch='B';
a=I;b=J;
a-=1;b-=1;
while(a>=0 && b>=0)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
a-=1;b-=1;
}
a=I;b=J;
a+=1;b+=1;
while(a<8 && b<8)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
a+=1;b+=1;
}
a=I;b=J;
a+=1;b-=1;
while(a>=0 && a<8 && b>=0 && b<8)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
a+=1;b-=1;
}
a=I;b=J;
a-=1;b+=1;
while(a>=0 && a<8 && b>=0 && b<8)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
a-=1;b+=1;
}
return 0;
}
bool ischeck_rook(int I,int J,int color)
{
int a=I,b=J;
char ch;
if(color)
ch='r';
else
ch='R';
a-=1;
while(a>=0 && b>=0)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
a-=1;
}
a=I;b=J;
b-=1;
while(a>=0 && b>=0)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
b-=1;
}
a=I;b=J;
b+=1;
while(b<8)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
b+=1;
}
a=I;b=J;
a+=1;
while(a<8)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
a+=1;
}
return 0;
}
bool ischeck_queen(int I,int J,int color)
{
int a=I,b=J;
char ch;
if(color)
ch='q';
else
ch='Q';
a-=1;b-=1;
while(a>=0 && b>=0)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
a-=1;b-=1;
}
a=I;b=J;
a+=1;b+=1;
while(a<8 && b<8)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
a+=1;b+=1;
}
a=I;b=J;
a+=1;b-=1;
while(a>=0 && a<8 && b>=0 && b<8)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
a+=1;b-=1;
}
a=I;b=J;
a-=1;b+=1;
while(a>=0 && a<8 && b>=0 && b<8)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
a-=1;b+=1;
}
a=I;b=J;
a-=1;
while(a>=0 && b>=0)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
a-=1;
}
a=I;b=J;b-=1;
while(a>=0 && b>=0)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
b-=1;
}
a=I;b=J;b+=1;
while(b<8)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
b+=1;
}
a=I;b=J;a+=1;
while(a<8)
{
if(board[a][b]==ch)
return 1;
else if(board[a][b]!='.')
break;
a+=1;
}
return 0;
}
int main()
{
bool f=0;
string blnk;
int kase=1;
IDX white_king,black_king;
while(cin>>board[0][0])
{
f=0;
if(board[0][0]=='K')
{
white_king.i=0;
white_king.j=0;
}
if(board[0][0]=='k')
{
black_king.i=0;
black_king.j=0;
}
if(board[0][0]!='.')
f=1;
for(int i=1;i<8;i++)
{
cin>>board[0][i];
if(board[0][i]!='.')
f=1;
if(board[0][i]=='K')
{
white_king.i=0;
white_king.j=i;
}
if(board[0][i]=='k')
{
black_king.i=0;
black_king.j=i;
}
}
for(int i=1;i<8;i++)
{
for(int j=0;j<8;j++)
{
cin>>board[i][j];
if(board[i][j]!='.')
f=1;
if(board[i][j]=='K')
{
white_king.i=i;
white_king.j=j;
}
if(board[i][j]=='k')
{
black_king.i=i;
black_king.j=j;
}
}
}
if(!f)
{
break;
}
else
{
getline(cin,blnk);
}
//black_check
f = isCheck_knight(black_king.i,black_king.j,0);
if(f)
{
cout<<"Game #"<<kase++<<": black king is in check.\n";
continue;
}
f = ischeck_king(black_king.i,black_king.j,0);
if(f)
{
cout<<"Game #"<<kase++<<": black king is in check.\n";
continue;
}
f = ischeck_bishop(black_king.i,black_king.j,0);
if(f)
{
cout<<"Game #"<<kase++<<": black king is in check.\n";
continue;
}
f = ischeck_rook(black_king.i,black_king.j,0);
if(f)
{
cout<<"Game #"<<kase++<<": black king is in check.\n";
continue;
}
//pawncheck
if(black_king.i+1<8 && black_king.j+1<8 && board[black_king.i+1][black_king.j+1]=='P')
{
cout<<"Game #"<<kase++<<": black king is in check.\n";
continue;
}
if(black_king.i+1<8 && black_king.j-1>=0 && board[black_king.i+1][black_king.j-1]=='P')
{
cout<<"Game #"<<kase++<<": black king is in check.\n";
continue;
}
f = ischeck_queen(black_king.i,black_king.j,0);
if(f)
{
cout<<"Game #"<<kase++<<": black king is in check.\n";
continue;
}
//white_check
f = isCheck_knight(white_king.i,white_king.j,1);
if(f)
{
cout<<"Game #"<<kase++<<": white king is in check.\n";
continue;
}
f = ischeck_king(white_king.i,white_king.j,1);
if(f)
{
cout<<"Game #"<<kase++<<": white king is in check.\n";
continue;
}
f = ischeck_bishop(white_king.i,white_king.j,1);
if(f)
{
cout<<"Game #"<<kase++<<": white king is in check.\n";
continue;
}
f = ischeck_rook(white_king.i,white_king.j,1);
if(f)
{
cout<<"Game #"<<kase++<<": white king is in check.\n";
continue;
}
//pawncheck
if(white_king.i-1>=0 && white_king.j-1>=0 && board[white_king.i-1][white_king.j-1]=='p')
{
cout<<"Game #"<<kase++<<": white king is in check.\n";
continue;
}
if(white_king.i-1>=0 && white_king.j+1<8 && board[white_king.i-1][white_king.j+1]=='p')
{
cout<<"Game #"<<kase++<<": white king is in check.\n";
continue;
}
f = ischeck_queen(white_king.i,white_king.j,1);
if(f)
{
cout<<"Game #"<<kase++<<": white king is in check.\n";
continue;
}
//cout<<black_king.i<<" "<<black_king.j<<"\n";
cout<<"Game #"<<kase++<<": no king is in check.\n";
}
return 0;
}