#include <iostream>
#include <cstdio>
#include <cmath>


using namespace std;
int a[3];
char b[3];

int main()
{
    a[0] = 1;
    while (scanf("%s",b) != EOF){
        swap(a[b[0] - 65],a[b[2] - 65]);
    }
    if (a[0] == 1)
        cout << "A" << endl;
    else if (a[1] == 1)
        cout << "B" << endl;
    else if (a[2] == 1)
        cout << "C" << endl;

    return 0;
}

