object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val stringS = sc.next()
    val stringT = sc.next()
    val valueS = sc.nextInt()
    val valueT = sc.nextInt()
    val pickedString = sc.next()

    val ans =
      if (pickedString == stringS) {
        val newValueS = valueS - 1
        s"$newValueS $valueT"
      } else {
        val newValueT = valueT - 1
        s"$valueS $newValueT"
      }

    println(ans)
  }
}
