str = input().split(" ")
S = str[0]
T = str[1]
num = input().split(" ")
NS = int(num[0])
NT = int(num[1])
U = input()

if S == U:
  print(NS - 1, end=" ")
  print(NT)
else:
  print(NS, end=" ")
  print(NT - 1) str = input().split(" ") str input().split(" ") ().split () input split " " S = str[0] S str[0] str 0 T = str[1] T str[1] str 1 num = input().split(" ") num input().split(" ") ().split () input split " " NS = int(num[0]) NS int(num[0]) int num[0] num 0 NT = int(num[1]) NT int(num[1]) int num[1] num 1 U = input() U input() input if S == U:
  print(NS - 1, end=" ")
  print(NT)
else:
  print(NS, end=" ")
  print(NT - 1) S == U S U print(NS - 1, end=" ") print NS - 1 NS 1 end=" " end " " print(NT) print NT print(NS, end=" ") print NS end=" " end " " print(NT - 1) print NT - 1 NT 1 num = input().split(" ") input().split(" ") num U = input() input() U str = input().split(" ") input().split(" ") str T = str[1] str[1] T NT = int(num[1]) int(num[1]) NT NS = int(num[0]) int(num[0]) NS S = str[0] str[0] S
str = input().split(" ")
S = str[0]
T = str[1]
num = input().split(" ")
NS = int(num[0])
NT = int(num[1])
U = input()

if S == U:
  print(NS - 1, end=" ")
  print(NT)
else:
  print(NS, end=" ")
  print(NT - 1)