#include<iostream>
#include<cstring>
using namespace std;
int a[5][5],b[5][5],tmp[5][5];
bool judge(){
for(int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
if(a[i][j]!=b[i][j])return 0;
}
}
return 1;
}
void copy(){
for(int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
tmp[i][j]=a[i][j];
}
}
}
void A(){
copy();
a[1][1]=tmp[1][3];
a[1][2]=tmp[2][3];
a[1][3]=tmp[3][3];
a[2][1]=tmp[1][2];
a[2][3]=tmp[3][2];
a[3][1]=tmp[1][1];
a[3][2]=tmp[2][1];
a[3][3]=tmp[3][1];
}
inline void B(){
for(int i=1;i<=3;i++)A();
}
void C(){
copy();
a[1][1]=tmp[1][3];
a[1][3]=tmp[1][1];
a[2][1]=tmp[2][3];
a[2][3]=tmp[2][1];
a[3][1]=tmp[3][3];
a[3][3]=tmp[3][1];
}
inline void D(){
C();
B();
B();
}
int main(){
for(int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
cin>>a[i][j];
}
}
for(int i=1;i<=3;i++){
for(int j=1;j<=3;j++){
cin>>b[i][j];
}
}
if(judge()){
cout<<"AB";
return 0;
}
A();
if(judge()){
cout<<"A";
return 0;
}
B();B();
if(judge()){
cout<<"B";
return 0;
}
A();C();
if(judge()){
cout<<"C";
return 0;
}
C();D();
if(judge()){
cout<<"D";
return 0;
}
D();A();A();
if(judge()){
cout<<"AA";
return 0;
}
A();A();A();C();
if(judge()){
cout<<"AC";
return 0;
}
C();B();B();C();
if(judge()){
cout<<"BC";
return 0;
}
cout<<"Poland cannot into space!!!";
return 0;
}