a = input().split()
b = list(map(int, input().split()))
c = input()
if a[0]==c:
  print(b[0]-1, b[1])
else:
  print(b[0], b[1]-1) a = input().split() a input().split() ().split () input split b = list(map(int, input().split())) b list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split c = input() c input() input if a[0]==c:
  print(b[0]-1, b[1])
else:
  print(b[0], b[1]-1) a[0]==c a[0] a 0 c print(b[0]-1, b[1]) print b[0]-1 b[0] b 0 1 b[1] b 1 print(b[0], b[1]-1) print b[0] b 0 b[1]-1 b[1] b 1 1 b = list(map(int, input().split())) list(map(int, input().split())) b c = input() input() c a = input().split() input().split() a
a = input().split()
b = list(map(int, input().split()))
c = input()
if a[0]==c:
  print(b[0]-1, b[1])
else:
  print(b[0], b[1]-1)