#include<iostream>
#include<vector>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
  char a,b,d;
  int in[3]={1};
  while(cin>>a>>d>>b){
    if(in[a-'A']||in[b-'A'])swap(in[a-'A'],in[b-'A']);
  }
  rep(i,3)if(in[i])cout<<(char)(i+'A')<<endl;
}