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

int main(int argc, char *argv[])
{
  char x,y;
  map<char,int> Map;
  Map['A'] = 1;
  while(scanf("%c,%c",&x,&y) !=EOF){
    swap(Map[x],Map[y]);
  }
  for(char i ='A';i<='C';i++){
    if(Map[i] ==1)
      cout <<i<<endl;
    }
  return 0;
}