#include<iostream>
#include<string>
using namespace std;

int main(){
  int cap[3]={1,0,0},tmp;
  int ta1[6]={0,0,1,1,2,2},ta2[6]={1,2,0,2,0,1};
  char comma;
  string ch1,ch2,mark[3]={"A","B","C"};
  string pa1[6]={"A","A","B","B","C","C"},pa2[6]={"B","C","A","C","A","B"};
  while(cin >> ch1 >> comma >> ch2){
    for(int i=0;i<6;i++){
      if(ch1 == pa1[i] && ch2 == pa2[i]){
	tmp = cap[ta1[i]];
	cap[ta1[i]] = cap[ta2[i]];
	cap[ta2[i]] = tmp;
	break;
      }
    }
  }
  for(int i=0;i<3;i++){
    if(cap[i] == 1){
      cout << mark[i] << endl;
    }
  }
}