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