#include<bits/stdc++.h>
using namespace std;
int main(){
  string str,s1,s2;
  pair<char,int> cup[3];
  cup[0]=make_pair('A',1);cup[1]=make_pair('B',0);cup[2]=make_pair('C',0);
  while(cin>>str){
    for(int i=0;i<3;i++){
      if(str[0]==cup[i].first){
	if(cup[i].second==0)
	  s1='A+i'+'0';
	else
	  s2='A+i'+'1';
      }
      if(str[2]==cup[i].first){
	if(cup[i].second==0)
	  s1='A+i'+'0';
	else
	  s2='A+i'+'1';
      }
    }
    if(s2[1]=='0'&&s1[1]=='0')
      continue;
    if(s2[1]=='1'&&s1[1]=='0'){
      for(int i=0;i<3;i++){
	if(s2[0]==cup[i].first)
	  cup[i].second=1;
	if(s1[0]==cup[i].first)
	  cup[i].second=0;
      }
    }else if(s2[1]=='0'&&s1[1]=='1'){
      for(int i=0;i<3;i++){
	if(s2[0]==cup[i].first)
	  cup[i].second=0;
	if(s1[0]==cup[i].first)
	  cup[i].second=1;
      }
    }
  }
  for(int i=0;i<3;i++)
    if(cup[i].second==1)
      cout<<cup[i].first<<endl;
  return 0;
}