#include <iostream>
#include <string>
#include <stdio.h>

void change(std::string a,std::string b,bool cup[]){
	int ir[2];
	if(a == "A"){
		ir[0]=0;
	}
	else if(a == "B"){
		ir[0]=1;
	}
	else{
		ir[0]=2;
	}
	if(b == "A"){
		ir[1]=0;
	}
	else if(b == "B"){
		ir[1]=1;
	}
	else{
		ir[1]=2;
	}
	bool ex = cup[ ir[0] ];
	cup[ ir[0] ] = cup[ ir[1] ];
	cup[ ir[1] ] = ex;
}

int main(){
	using namespace std;
	bool cup[3];
	cup[0] = true;
	cup[1] = false;
	cup[2] = false;
	std::string pl[2];
	char mj[32];
	while( scanf("%s",&mj)!=EOF ){
		pl[0] = mj;
		cin >> pl[1];
		change(pl[0],pl[1],cup);
	}
	if(cup[0]){
		cout << "A" << endl;
	}
	else if(cup[1]){
		cout << "B" << endl;
	}
	else{
		cout << "C" << endl;
	}
	return 0;
}