#include <cstdio>
#include<iostream>
#include<algorithm>

using namespace std;
 
int main(void){

	int cup[3]={0};
	char inp,gav,inp2;

	cup[0]=1;
	while(cin>>inp>>gav>>inp2){
		swap(cup[inp-'A'],cup[inp2-'A']);
	}

	for(int i=0;i<3;i++){
		if(cup[i]==1) cout<<(char)(i+'A')<<endl;
	}

    return 0;
}