#include <iostream>
using namespace std;
int main(){
  int a[3]={1,0,0},b;char c[3];
  while(cin>>c){
    b=a[(c[0]-'A')];
    a[c[0]-'A']=a[(c[2]-'A')];
    a[(c[2]-'A')]=b;
  }
  for(b=0;i<3;i++)if(a[i])cout<<(char)('A'+i)<<endl;
}