s, t = map(str, input().split())
a, b = map(int, input().split())

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

query = input()
if query == s:
    a -= 1
else:
    b -= 1
print(str(a) + " " + str(b))