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

int main() {
  char a, b;
  int ball[3] = {1,0,0};
  while(scanf("%c,%c", &a, &b) != EOF) {
    swap(ball[a-'A'], ball[b-'A']);
  }
  for(int i = 0; i < 3; ++i) {
    if(ball[i]) printf("%c\n", i+'A');
  }
  return 0;
}