st = input().split()
S = st[0]
T = st[1]

ab = input().split()
A = int(ab[0])
B = int(ab[1])
U = input()

new_a = A - 1 if S == U else A
new_b = B-1 if T == U else B

print("{} {}".format(new_a, new_b)) st = input().split() st input().split() ().split () input split S = st[0] S st[0] st 0 T = st[1] T st[1] st 1 ab = input().split() ab input().split() ().split () input split A = int(ab[0]) A int(ab[0]) int ab[0] ab 0 B = int(ab[1]) B int(ab[1]) int ab[1] ab 1 U = input() U input() input new_a = A - 1 if S == U else A new_a A - 1 if S == U else A S == U S U A - 1 A 1 A new_b = B-1 if T == U else B new_b B-1 if T == U else B T == U T U B-1 B 1 B print("{} {}".format(new_a, new_b)) print "{} {}".format(new_a, new_b) "{} {}".format "{} {}" format new_a new_b B = int(ab[1]) int(ab[1]) B ab = input().split() input().split() ab T = st[1] st[1] T new_b = B-1 if T == U else B B-1 if T == U else B new_b S = st[0] st[0] S new_a = A - 1 if S == U else A A - 1 if S == U else A new_a U = input() input() U st = input().split() input().split() st A = int(ab[0]) int(ab[0]) A
st = input().split()
S = st[0]
T = st[1]

ab = input().split()
A = int(ab[0])
B = int(ab[1])
U = input()

new_a = A - 1 if S == U else A
new_b = B-1 if T == U else B

print("{} {}".format(new_a, new_b))
