fun main(args: Array<String>) {
    val s = (0..2).map {readLine()!!.toList().map {it-'a'}.toMutableList() }
    var turn = 0
    while (s[turn].isNotEmpty()) {
        turn = s[turn].removeAt(0)
    }
    println(('A'+turn).toChar())
}