#include<iostream>
using namespace std;
int main(){
  int b[3],k,i=-1,j=-1;
  char d[3];
  b[0] = 1;
  b[1] = 0;
  b[2] = 0;
  while(cin>>d[0]>>d[1]>>d[2]){
    if(d[0]=='A'||d[2]=='A'){
      if(i==-1) i = 0;
      else if(i!=-1) j = 0;
    }
     if(d[0]=='B'||d[2]=='B'){
      if(i==-1) i = 1;
      else if(i!=-1) j = 1;
    }
   if(d[0]=='C'||d[2]=='C'){
      if(i==-1) i = 2;
      else if(i!=-1) j = 2;
    }
   k = b[i];
   b[i] = b[j];
   b[j] = k;
   i = -1;
   j = -1;
  }
  for(int o=0;o<3;o++){
    if(b[o]==1){
      if(o==0) cout << 'A' << endl;
      if(o==1) cout << 'B' << endl;
      if(o==2) cout << 'C' << endl;
    }
  }
  return 0;
}