#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
  char a,b;
  int cup[3] = {1,0,0};  

  while(scanf("%c,%c ",&a,&b) != EOF){
    swap( cup[a-'A'],cup[b-'A']);
  }

  for(int i = 0 ; i < 3 ; i++){
    if(cup[i])printf("%c\n",'A'+i);
  }

  return 0;
}