#include <iostream>
using namespace std;
#define REP(i,n) for (int i=0; i<n; i++)

int main(){
	char a,b,c;
	int x[3]={1,0,0};
	while (cin>>a>>c>>b){
		int k = x[a-'A'];
		x[a-'A'] = x[b-'A'];
		x[b-'A'] = k;
	}
	REP(i,3)
		if (x[i]==1) cout<<char(i+'A')<<endl;
}