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

void main() {
    string[] input = new string[](2);
    bool[] cup = new bool[](3);

    cup.fill(false);
    cup[0] = true;
    while ((input = readln.chomp.split(",")).length != 0) {
        swap(cup[(input[0][0] - 'A').to!int], cup[(input[1][0] - 'A').to!int]);
    }

    foreach (i; 0..cup.length) {
        if (cup[i]) {
           writeln((i + 'A').to!char);
           break;
        }
    }
}