import std.cstream;
import std.stdio;
import std.algorithm;

void main(){

int[char] cup=['A':1,'B':0,'C':0];


while(!din.eof()){
char[] ion = din.readLine();
swap(cup[ion[0]],cup[ion[2]]);
}

if(cup['A'] == 1)writeln("A");
else if(cup['B'] == 1)writeln("B");
else writeln("C");
}