#include <bits/stdc++.h>

using namespace std;

const string ord = "ABC";

int main() {
    int ball[] = {1, 0, 0};
    string s;
    while (cin >> s) {
        if (s == "A,B" || s == "B,A") swap(ball[0], ball[1]);
        if (s == "B,C" || s == "C,B") swap(ball[1], ball[2]);
        if (s == "C,A" || s == "A,C") swap(ball[2], ball[0]);
    }

    for (int i = 0; i < 3; i++)
        if (ball[i]) cout << ord[i] << endl;
    
    return 0;
}
