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

void main() {
  bool[] state = new bool[](3);
  state[0] = true; state[1] = false; state[2] = false;
  while(true) {
    string line = readln.chomp;
    if (stdin.eof) break;
    auto data = line.split(",").map!((x) => to!(uint)(x[0] - 'A')).array;
    swap(state[data[0]], state[data[1]]);
  }
  foreach(i, s; state) if(s) writeln(to!(char)(i + 'A'));
}