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

int main()
{
	bool ball[3] = { true, false, false};
	string str;
	
	while(cin >> str)
	{
		int x = str[0]-'A', y = str[2]-'A';
		int temp =ball[x];
	ball[x] = ball[y];
	ball[y] = temp;
	}
	
	cout << (ball[0] ? 'A' : ball[1] ? 'B' : ' C ') << endl;
	
	return 0;
}