#include<iostream>
#include<map>
#include<stdio.h>
using namespace std;

int main(){
	map<char, int> cup;
	char s1, s2, hoge;
	cup['A'] = 1;
	cup['B'] = cup['C'] = 0;
	while(cin >> s1 >> hoge >> s2){
		swap(cup[s1], cup[s2]);
	}
	for(char i = 'A'; i <= 'C'; i++){
		if(cup[i]) cout << i << endl;
	}
}