#include<iostream>
#include<cstdio>
using namespace std;
int cup[3]={1,0,0};
int main(){
  for(;;){
    char a,b;
    int x,y,z;
    if(scanf("%c,%c%*c",&a,&b) == EOF) break;
    x = a-'A';
    y = b-'A';
    z = cup[x];
    cup[x] = cup[y];
    cup[y] = z;
  }
  for(int i=0; i<3; i++) if(cup[i] == 1) cout <<(char)('A'+i)<<endl;
  return 0;
}