#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int get(string s)
{
	if (s == "A")
	{
		return 0;
	}
	else if (s == "B")
	{
		return 1;
	}
	else
	{
		return 2;
	}
}

int main()
{
	vector<int> a = {1, 0, 0};

	string s;
	for (; cin >> s;)
	{
		int x = get(s.substr(0, 1));
		int y = get(s.substr(2, 1));

		swap(a.at(x), a.at(y));
	}

	string st[] = {"A", "B", "C"};
	int i;
	for (i = 0; i < 3; i++)
	{
		if (a.at(i) == 1)
		{
			break;
		}
	}

	cout << st[i] << endl;
}
