object Main extends App {
  val src = io.Source.stdin.getLines.map(_.split(",").map(_.head)).toList
  val org = ('A' to 'C').toList

  def func(org: List[Char], ope: Array[Char]) = {
    org.updated(org.indexOf(ope(0)), ope(1)).updated(org.indexOf(ope(1)), ope(0))
  }
  println((org /: src)(func).head)
}