#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  string s;
  int a[2],x[3]={1};
  while(cin >>s){
    for(int i=0; i<2; i++){
      if(s[i*2] == 'A') a[i] = 0;
      if(s[i*2] == 'B') a[i] = 1;
      if(s[i*2] == 'C') a[i] = 2;
    }
    swap(x[a[0]],x[a[1]]);
  }
  if(x[0] == 1) cout <<'A'<<endl;
  if(x[1] == 1) cout <<'B'<<endl;
  if(x[2] == 1) cout <<'C'<<endl;
  return 0;
}