#include<iostream>
#include<stack>
#include<queue>
#include<set>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<cmath>
#define ll long long
#define oo 1000000007
#define MAXN 100010
using namespace std;
int a[30],ansm;
char way[1005];
bool judge()
{
if (a[7]==a[8] && a[7]==a[9] && a[7]==a[12] &&
a[7]==a[13] && a[7]==a[16] && a[7]==a[17] && a[7]==a[18]) return true;
return false;
}
int cnt()
{
int S[4];
S[1]=S[2]=S[3]=0;
S[a[7]]++,S[a[8]]++,S[a[9]]++,S[a[12]]++;
S[a[13]]++,S[a[16]]++,S[a[17]]++,S[a[18]]++;
return 8-max(S[1],max(S[2],S[3]));
}
bool DFSID(int p,int t)
{
if (p+cnt()>t) return false;
int x[30];
if (judge())
{
ansm=a[7];
return true;
}
memcpy(x,a,sizeof(x));
//-----------A-------------
a[1]=x[3],a[3]=x[7],a[7]=x[12],a[12]=x[16],a[16]=x[21],a[21]=x[23],a[23]=x[1];
way[p+1]='A';
if (DFSID(p+1,t)) return true;
memcpy(a,x,sizeof(x));
//-----------B-------------
a[2]=x[4],a[4]=x[9],a[9]=x[13],a[13]=x[18],a[18]=x[22],a[22]=x[24],a[24]=x[2];
way[p+1]='B';
if (DFSID(p+1,t)) return true;
memcpy(a,x,sizeof(x));
//-----------C-------------
a[11]=x[10],a[10]=x[9],a[9]=x[8],a[8]=x[7],a[7]=x[6],a[6]=x[5],a[5]=x[11];
way[p+1]='C';
if (DFSID(p+1,t)) return true;
memcpy(a,x,sizeof(x));
//-----------D-------------
a[20]=x[19],a[19]=x[18],a[18]=x[17],a[17]=x[16],a[16]=x[15],a[15]=x[14],a[14]=x[20];
way[p+1]='D';
if (DFSID(p+1,t)) return true;
memcpy(a,x,sizeof(x));
//-----------E-------------
a[24]=x[22],a[22]=x[18],a[18]=x[13],a[13]=x[9],a[9]=x[4],a[4]=x[2],a[2]=x[24];
way[p+1]='E';
if (DFSID(p+1,t)) return true;
memcpy(a,x,sizeof(x));
//-----------F-------------
a[23]=x[21],a[21]=x[16],a[16]=x[12],a[12]=x[7],a[7]=x[3],a[3]=x[1],a[1]=x[23];
way[p+1]='F';
if (DFSID(p+1,t)) return true;
memcpy(a,x,sizeof(x));
//-----------G-------------
a[14]=x[15],a[15]=x[16],a[16]=x[17],a[17]=x[18],a[18]=x[19],a[19]=x[20],a[20]=x[14];
way[p+1]='G';
if (DFSID(p+1,t)) return true;
memcpy(a,x,sizeof(x));
//-----------H-------------
a[5]=x[6],a[6]=x[7],a[7]=x[8],a[8]=x[9],a[9]=x[10],a[10]=x[11],a[11]=x[5];
way[p+1]='H';
if (DFSID(p+1,t)) return true;
memcpy(a,x,sizeof(x));
return false;
}
int main()
{
int i,x;
while (~scanf("%d",&a[1]) && a[1])
{
for (i=2;i<=24;i++) scanf("%d",&a[i]);
if (judge()) printf("No moves needed\n%d\n",a[7]);
else
{
for (i=1;i<=1000;i++)
if (DFSID(0,i)) break;
for (x=1;x<=i;x++) printf("%c",way[x]);
printf("\n%d\n",ansm);
}
}
return 0;
}