w = list(input().split())
n = list(map(int, input().split()))
u = input()

if u == w[0]:
  print(n[0]-1,n[1])
else:
  print(n[0],n[1]-1) w = list(input().split()) w list(input().split()) list input().split() ().split () input split n = list(map(int, input().split())) n list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split u = input() u input() input if u == w[0]:
  print(n[0]-1,n[1])
else:
  print(n[0],n[1]-1) u == w[0] u w[0] w 0 print(n[0]-1,n[1]) print n[0]-1 n[0] n 0 1 n[1] n 1 print(n[0],n[1]-1) print n[0] n 0 n[1]-1 n[1] n 1 1 n = list(map(int, input().split())) list(map(int, input().split())) n u = input() input() u w = list(input().split()) list(input().split()) w
w = list(input().split())
n = list(map(int, input().split()))
u = input()

if u == w[0]:
  print(n[0]-1,n[1])
else:
  print(n[0],n[1]-1)