c = input().split()
n = list(map(int, input().split()))
if input() == c[0]:
    n[0] -= 1
else:
    n[1] -= 1
print(n[0], n[1]) c = input().split() c 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 if input() == c[0]:
    n[0] -= 1
else:
    n[1] -= 1 input() == c[0] input() input c[0] c 0 n[0] -= 1 n[0] n 0 1 n[1] -= 1 n[1] n 1 1 print(n[0], n[1]) print n[0] n 0 n[1] n 1 c = input().split() input().split() c n = list(map(int, input().split())) list(map(int, input().split())) n
c = input().split()
n = list(map(int, input().split()))
if input() == c[0]:
    n[0] -= 1
else:
    n[1] -= 1
print(n[0], n[1])