l = list(input() for _ in range(3))
str1 , str2 = l[0].split()
num1 , num2 = map(int,l[1].split())
if l[2] == str1:
  num1 -= 1
  print(num1 , num2)
else:
  num2 -= 1
  print(num1 , num2) l = list(input() for _ in range(3)) l list(input() for _ in range(3)) list input() input str1 , str2 = l[0].split() str1 l[0].split() [0].split [0] l 0 split str2 num1 , num2 = map(int,l[1].split()) num1 map(int,l[1].split()) map int l[1].split() [1].split [1] l 1 split num2 if l[2] == str1:
  num1 -= 1
  print(num1 , num2)
else:
  num2 -= 1
  print(num1 , num2) l[2] == str1 l[2] l 2 str1 num1 -= 1 num1 1 print(num1 , num2) print num1 num2 num2 -= 1 num2 1 print(num1 , num2) print num1 num2 num2 = map(int,l[1].split()) map(int,l[1].split()) num2 num1 -= 1 1 num1 l = list(input() for _ in range(3)) list(input() for _ in range(3)) l str1 , str2 = l[0].split() l[0].split() str1 str2 = l[0].split() l[0].split() str2 num2 -= 1 1 num2 num1 , num2 = map(int,l[1].split()) map(int,l[1].split()) num1
l = list(input() for _ in range(3))
str1 , str2 = l[0].split()
num1 , num2 = map(int,l[1].split())
if l[2] == str1:
  num1 -= 1
  print(num1 , num2)
else:
  num2 -= 1
  print(num1 , num2)