s, t = input().split(" ")
a, b = list(map(int, input().split()))
u = input()

if (s == u):
    a -= 1
if (t == u):
    b -= 1
print(str(a) + " " + str(b)) s, t = input().split(" ") s input().split(" ") ().split () input split " " t a, b = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split b u = input() u input() input if (s == u):
    a -= 1 s == u s u a -= 1 a 1 if (t == u):
    b -= 1 t == u t u b -= 1 b 1 print(str(a) + " " + str(b)) print str(a) + " " + str(b) str(a) + " " str(a) str a " " str(b) str b a -= 1 1 a b -= 1 1 b t = input().split(" ") input().split(" ") t b = list(map(int, input().split())) list(map(int, input().split())) b s, t = input().split(" ") input().split(" ") s a, b = list(map(int, input().split())) list(map(int, input().split())) a u = input() input() u
s, t = input().split(" ")
a, b = list(map(int, input().split()))
u = input()

if (s == u):
    a -= 1
if (t == u):
    b -= 1
print(str(a) + " " + str(b))