//UVA253Cube Painting
#include
#include
#include
char s[10] = {0};
char tmp[10] = {0};
char t[10] = {0};
const int length = 6;
void Trans(char t[], int a, int b, int c, int d, int e, int f) {
t[0] = tmp[a - 1]; t[1] = tmp[b - 1]; t[2] = tmp[c - 1]; t[3] = tmp[d - 1]; t[4] = tmp[e - 1]; t[5] = tmp[f - 1];
}
int Judge() {
memset(t, 0, sizeof(t));
int count = 0;
Trans(t, 1, 2, 3, 4, 5, 6);//1:12345
if(!strcmp(s, t)) return 1;
Trans(t, 1, 5, 4, 3, 2, 6);//2:154326
if(!strcmp(s, t)) return 1;
Trans(t, 1, 4, 2, 5, 3, 6);//3:142536
if(!strcmp(s, t)) return 1;
Trans(t, 1, 3, 5, 2, 4, 6);//4:135246
if(!strcmp(s, t)) return 1;
Trans(t, 3, 2, 6, 1, 5, 4);//5:326154
if(!strcmp(s, t)) return 1;
Trans(t, 3, 5, 1, 6, 2, 4);//6:351624
if(!strcmp(s, t)) return 1;
Trans(t, 3, 1, 2, 5, 6, 4);//7:312564
if(!strcmp(s, t)) return 1;
Trans(t, 3, 6, 5, 2, 1, 4);//8:365214
if(!strcmp(s, t)) return 1;
Trans(t, 6, 2, 4, 3, 5, 1);//9:624351
if(!strcmp(s, t)) return 1;
Trans(t, 6, 5, 3, 4, 2, 1);//10:653421
if(!strcmp(s, t)) return 1;
Trans(t, 6, 3, 2, 5, 4, 1);//11:632541
if(!strcmp(s, t)) return 1;
Trans(t, 6, 4, 5, 2, 3, 1);//12:645231
if(!strcmp(s, t)) return 1;
Trans(t, 4, 2, 1, 6, 5, 3);//13:421653
if(!strcmp(s, t)) return 1;
Trans(t, 4, 5, 6, 1, 2, 3);//14:456123
if(!strcmp(s, t)) return 1;
Trans(t, 4, 6, 2, 5, 1, 3);//15:462513
if(!strcmp(s, t)) return 1;
Trans(t, 4, 1, 5, 2, 6, 3);//16:415263
if(!strcmp(s, t)) return 1;
Trans(t, 2, 6, 3, 4, 1, 5);//17:263415
if(!strcmp(s, t)) return 1;
Trans(t, 2, 4, 6, 1, 3, 5);//18:246135
if(!strcmp(s, t)) return 1;
Trans(t, 2, 1, 4, 3, 6, 5);//19:214365
if(!strcmp(s, t)) return 1;
Trans(t, 2, 3, 1, 6, 4, 5);//20:231645
if(!strcmp(s, t)) return 1;
Trans(t, 5, 1, 3, 4, 6, 2);//21:513462
if(!strcmp(s, t)) return 1;
Trans(t, 5, 6, 4, 3, 1, 2);//22:564312
if(!strcmp(s, t)) return 1;
Trans(t, 5, 4, 1, 6, 3, 2);//23:541632
if(!strcmp(s, t)) return 1;
Trans(t, 5, 3, 6, 1, 4, 2);//24:536142
if(!strcmp(s, t)) return 1;
return 0;
}
int main() {
char c;
while((c = getchar()) != EOF) {
memset(s, 0, sizeof(s));
memset(s, 0, sizeof(s));
s[0] = c;
tmp[length] = s[length] = 0;
for(int i = 1; i <= 5; i++) s[i] = getchar();
for(int i = 0; i < length; i++) tmp[i] = getchar();
getchar();//吸收回车
if(Judge()) printf("TRUE\n");
else printf("FALSE\n");
}
return 0;
}