#include<iostream>
#include<vector>
using namespace std;
int main(){

  vector<int>a;
  int tmp;
  char b,c;
  char d;
  a.push_back(1);
  a.push_back(0);
  a.push_back(0);
  
  while(cin >> b >> d >> c!='\0'){

    if(a[b-'A']!=0||a[c-'A']!=0)
      swap(a[b-'A'],a[c-'A']);


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