#include<iostream>
#include<string>
using namespace std;

int main(){
	bool existBall[3] = { 1, 0, 0 };
	bool tm;

	char a, b;
	string s;

	while (getline(cin, s)){
		a = s[0];
		b = s[2];
		
		tm = existBall[b - 'A'];
		existBall[b - 'A'] = existBall[a - 'A'];
		existBall[a - 'A'] = tm;
	}

	for (int i = 0; i < 3;++i)
	if (existBall[i])
		cout << 'A' + i << endl;
	
	return 0;

}