#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,p=1,win,chess[10][9]={
5,4,3,2,1,2,3,4,5,
0,0,0,0,0,0,0,0,0,
6,0,0,0,0,0,0,0,6,
7,0,7,0,7,0,7,0,7,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
7,0,7,0,7,0,7,0,7,
6,0,0,0,0,0,0,0,6,
0,0,0,0,0,0,0,0,0,
5,4,3,2,1,2,3,4,5},col[10][9]={
1,1,1,1,1,1,1,1,1,
0,0,0,0,0,0,0,0,0,
1,0,0,0,0,0,0,0,1,
1,0,1,0,1,0,1,0,1,
0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,
2,0,2,0,2,0,2,0,2,
2,0,0,0,0,0,0,0,2,
0,0,0,0,0,0,0,0,0,
2,2,2,2,2,2,2,2,2};
string sname[8]={"NA","captain","guard","elephant","horse","car","duck","soldier"},scol[3]={"","red","blue"};
bool pd(int x,int y,int ex,int ey){
int f=0;
if(chess[x][y]==5){
if(y==ey){
for(int i=min(x,ex)+1;i<max(x,ex);i++)
if(chess[i][y])
f=1;
}else if(x==ex){
for(int i=min(y,ey)+1;i<max(y,ey);i++)
if(chess[x][i])
f=1;
}else f=1;
}else if(chess[x][y]==4){
if((abs(x-ex)==2&&abs(y-ey)==1)||(abs(x-ex)==1&&abs(y-ey)==2)){
int sx=(ex-x)/2,sy=(ey-y)/2;
if(col[x+sx][y+sy])f=1;
}else f=1;
}else if(chess[x][y]==3){
if(abs(x-ex)==2&&abs(y-ey)==2){
int sx=(ex-x)/2,sy=(ey-y)/2;
if(col[x+sx][y+sy])f=1;
}else f=1;
}else if(chess[x][y]==1){
if(!((abs(x-ex)==1&&abs(y-ey)==0)||(abs(x-ex)==0&&abs(y-ey)==1)))
f=1;
}else if(chess[x][y]==7){
if((abs(x-ex)>1||abs(y-ey)>1))
f=1;
}else if(chess[x][y]==2){
if(abs(x-ex)!=1||abs(y-ey)!=1)
f=1;
}else{
if(abs(x-ex)==3&&abs(y-ey)==2){
int sx=(ex-x)/3,sy=(ey-y)/2;
if(col[x+sx][y]||col[x+sx*2][y+sy])f=1;
}else if(abs(x-ex)==2&&abs(y-ey)==3){
int sx=(ex-x)/2,sy=(ey-y)/3;
if(col[x+sx][y+sy*2]||col[x][y+sy])f=1;
}else f=1;
}
return f;
}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>n;
while(n--){
int x,y,ex,ey,f=0;
cin>>x>>y>>ex>>ey;
f=pd(x,y,ex,ey);
if(win||ex>9||ey>8||x>9||y>8||f||col[x][y]==col[ex][ey]||(!chess[x][y])||col[x][y]!=p){
cout<<"Invalid command\n";
continue;
}
cout<<scol[p]<<' '<<sname[chess[x][y]]<<';';
if(col[ex][ey])cout<<scol[col[ex][ey]]<<' ';
cout<<sname[chess[ex][ey]]<<';';
if(chess[ex][ey]==1)win=1;
col[ex][ey]=0;chess[ex][ey]=0;
swap(col[x][y],col[ex][ey]);
swap(chess[x][y],chess[ex][ey]);
f=0;
for(int ex=0;ex<10;ex++)
for(int ey=0;ey<9;ey++)
if(chess[ex][ey]==1)
for(int x=0;x<10;x++)
for(int y=0;y<9;y++)
if(chess[x][y]&&col[x][y]!=col[ex][ey])
f|=(!pd(x,y,ex,ey));
if(f)cout<<"yes";
else cout<<"no";
p=3-p;
if(win)cout<<";yes\n";
else cout<<";no\n";
}
return 0;
}