import std.stdio, std.string, std.conv, std.algorithm;

void main()
{
    bool[3] cups;
    cups[0] = true;
    while(true)
    {
        auto line = readln;
        if(!line)break;
        auto f = line.chomp.split(",");
        swap(cups[f[0][0] - 'A'], cups[f[1][0] - 'A']);
    }
    foreach(i, cup; cups)
    {
        if(cup) writeln(cast(char)('A' + i));
    }
}