s, t = input().split()
a, b = [int(i) for i in input().split()]
u = input()
if s == u:
  a -= 1
elif t == u:
  b -= 1
print(a, b) s, t = input().split() s input().split() ().split () input split t int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i a, b = [int(i) for i in input().split()] a [int(i) for i in input().split()] b u = input() u input() input if s == u:
  a -= 1
elif t == u:
  b -= 1 s == u s u a -= 1 a 1 elif t == u:
  b -= 1 t == u t u b -= 1 b 1 print(a, b) print a b s, t = input().split() input().split() s a, b = [int(i) for i in input().split()] [int(i) for i in input().split()] a u = input() input() u t = input().split() input().split() t a -= 1 1 a b = [int(i) for i in input().split()] [int(i) for i in input().split()] b b -= 1 1 b
s, t = input().split()
a, b = [int(i) for i in input().split()]
u = input()
if s == u:
  a -= 1
elif t == u:
  b -= 1
print(a, b)