#include <iostream>
#include <cstdio>
using namespace std;
int main(){
      int x,y,is[3]={1,0,0};
      while(scanf("%d,%d",&x,&y)){
            if(is[(int)(x-'A')])
            {
                  is[(int)(x-'A')]=0;
                  is[(int)(y-'A')]=1;
            }
            else if(is[(int)(y-'A')])
            {
                  is[(int)(y-'A')]=0;
                  is[(int)(x-'A')]=1;
            }
      }
      for(int i=0;i<3;i++)if(is[i])cout<<(char)(i+'A')<<endl;
}