#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(void){
    int a[3] = {0,1,2};
    int b , c ;
    while(scanf("%d,%d",&b,&c)){
        swap(a[b-'A'],a[c-'A']);
        
    }
    cout<<char(a[0]+'A')<<endl;

}