#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    char ch, f, s;
    bool cup[3];

    cup[0] = true;
    cup[1] = cup[2] = false;
    while (cin >> f >> ch >> s) {
        swap(cup[f - 'A'], cup[s - 'A']);
    }
    for (int i = 0; i < 3; i++)
        if (cup[i])
            cout << char(i + 'A') << endl;

    return 0;
}