bool zero(double x)
{
if(fabs(x)<=eps)return true;
return false;
}
bool equal_24(double a[],int n)
{
if(n==1)
if(zero(a[0]-24))return true;
else return false;
double b[5];
for(int i=0; i<n-1; i++)
for(int j=i+1; j<n; j++)
{
int cont=0;
for(int k=0; k<n; k++)
if(k!=i&&k!=j)b[cont++]=a[k];
b[cont]=a[i]+a[j];
if(equal_24(b,n-1))return true;
b[cont]=a[i]-a[j];
if(equal_24(b,n-1))return true;
b[cont]=a[j]-a[i];
if(equal_24(b,n-1))return true;
b[cont]=a[i]*a[j];
if(equal_24(b,n-1))return true;
if(!zero(a[j]))
{
b[cont]=a[i]/a[j];
if(equal_24(b,n-1))return true;
}
if(!zero(a[i]))
{
b[cont]=a[j]/a[i];
if(equal_24(b,n-1))return true;
}
}
return false;
}
int main()
{
int T;
double a[5];
while(~scanf("%lf%lf%lf%lf",&a[0],&a[1],&a[2],&a[3]))
{
if(zero(a[0])&&zero(a[1])&&zero(a[2])&&zero(a[3]))return 0;
if(equal_24(a,4))printf("YES\n");
else printf("NO\n");
}
return 0;
}
int a[35],cont;
void dfs(int x,int op)
{
if(a[x]==op)return;
if(x==1&&a[1]==1-op)
{
a[1]=op;
printf("第%d步: ",cont++);
if(op==1)printf("把1套上\n");
else printf("把1取下\n");
return;
}
if(a[x-1]==0)dfs(x-1,1);
for(int i=x-2; i>=1; i--)
if(a[i]==1)dfs(i,0);
a[x]=op;
printf("第%d步: ",cont++);
if(op==1)printf("把%d套上\n",x);
else printf("把%d取下\n",x);
}
void init(void)
{
cont=1;
memset(a,0,sizeof(a));
}
int main()
{
int n;
while(~scanf("%d",&n))
{
init();
for(int i=n; i>=1; i--)
dfs(i,1);
}
return 0;
}
int hang[15][15];
int lie[15][15];
int kuai[15][15];
char a[15][15];
int flag=0;
int judge(int x,int y)
{
if(x>=1&&x<=3&&y>=1&&y<=3)return 1;
if(x>=1&&x<=3&&y>=4&&y<=6)return 2;
if(x>=1&&x<=3&&y>=7&&y<=9)return 3;
if(x>=4&&x<=6&&y>=1&&y<=3)return 4;
if(x>=4&&x<=6&&y>=4&&y<=6)return 5;
if(x>=4&&x<=6&&y>=7&&y<=9)return 6;
if(x>=7&&x<=9&&y>=1&&y<=3)return 7;
if(x>=7&&x<=9&&y>=4&&y<=6)return 8;
if(x>=7&&x<=9&&y>=7&&y<=9)return 9;
}
void init(void)
{
for(int i=1; i<=9; i++)
for(int j=1; j<=9; j++)
{
hang[i][a[i][j]-'0']=1;
lie[j][a[i][j]-'0']=1;
kuai[judge(i,j)][a[i][j]-'0']=1;
}
}
void dfs(void)
{
if(flag)return;
int x,y,t;
flag=1;
for(int i=1; i<=9; i++)
for(int j=1; j<=9; j++)
if(a[i][j]=='0')
{
x=i;
y=j;
flag=0;
break;
}
if(flag)
{
for(int i=1;i<=9;i++)
printf("%s\n",a[i]+1);
return;
}
t=judge(x,y);
for(int i=1;i<=9;i++)
if(!hang[x][i]&&!lie[y][i]&&!kuai[t][i])
{
a[x][y]=i+'0';
hang[x][i]=1;
lie[y][i]=1;
kuai[t][i]=1;
dfs();
hang[x][i]=0;
lie[y][i]=0;
kuai[t][i]=0;
a[x][y]='0';
}
}
int main()
{
int T;
scanf("%d",&T);
while(T--)
{
memset(hang,0,sizeof(hang));
memset(lie,0,sizeof(lie));
memset(kuai,0,sizeof(kuai));
for(int i=1; i<=9; i++)
scanf("%s",a[i]+1);
init();
flag=0;
dfs();
}
return 0;
}
int cont=1;
char ans[100000];
int dx[]={-3,-1,1,3};
char dop[]={'u','l','r','d'};
bool bo[10000000];
struct node
{
int x[10];
int pre,id;
char op;
}a[362885];
ll qpow(int x,int y)
{
ll res=1;
while(y)
{
if(y&1)res*=x;
y>>=1;x*=x;
}
return res;
}
bool vis(node y)
{
ll res=0;
for(int i=1;i<=9;i++)
res+=(qpow(10,i-1)*y.x[10-i]);
if(bo[res%9999991]==1)return false;
bo[res%9999991]=1;
return true;
}
int findzero(node y)
{
for(int i=1;i<=9;i++)
if(y.x[i]==0)return i;
}
queue<node>Q;
void bfs(void)
{
int i;
node t;
while(!Q.empty())
{
t=Q.front();
Q.pop();
for(i=1;i<=8;i++)
if(t.x[i]!=i)break;
if(i==9)
{
int hh=0;
while(t.pre!=0)
{
t=a[t.id];
ans[hh++]=t.op;
t.id=a[t.id].pre;
}
for(i=hh-1;i>=0;i--)
printf("%c",ans[i]);
printf("\n");
return;
}
int zero=findzero(t);
int zeromosan=zero%3;
for(i=0;i<4;i++)
{
if(zeromosan==0&&i==2)continue;
if(zeromosan==1&&i==1)continue;
int now=zero+dx[i];
if(now>=1&&now<=9)
{
a[cont]=t;
swap(a[cont].x[zero],a[cont].x[now]);
if(vis(a[cont]))
{
a[cont].op=dop[i];
a[cont].pre=t.id;
a[cont].id=cont;
Q.push(a[cont]);
cont++;
}
}
}
}
printf("unsolvable\n");
}
int main()
{
char s[10][2];
for(int i=1;i<=9;i++)
scanf("%s",s[i]);
for(int i=1;i<=9;i++)
if(s[i][0]!='x')a[0].x[i]=(int)(s[i][0]-'0');
else a[0].x[i]=0;
a[0].id=0;
a[0].pre=0;
a[0].op=0;
Q.push(a[0]);
vis(a[0]);
bfs();
return 0;
}