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

void main()
{
    bool[3] b;b[0]=true;
    foreach(s;stdin.byLine())
        swap(b[s[0]-'A'],b[s[2]-'A']);
    foreach(i,v;b) if(v) writeln(cast(char)('A'+i));
}