#include<iostream>
#include<cstdio>
using namespace std;
main(){
	string str;
	int ball[3]={1,0,0};
	while(cin>>str){
		int a=str[0]-65;
		int b=str[2]-65;
		int tmp=ball[b];
		ball[b]=ball[a];
		ball[a]=tmp;
	}
	for(int i=0;i<3;++i){
		if(ball[i]==1){
			string s;
			s+=i+65;
			cout<<s<<endl;
			break;
		}
	}
}