s,t = input().split()
a,b = [int(x) for x in input().split()]
u = input()
if s == u:
  print(str(a-1) + " " + str(b))
else:
  print(str(a) + " " + str(b-1)) 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 s == u:
  print(str(a-1) + " " + str(b))
else:
  print(str(a) + " " + str(b-1)) s == u s u print(str(a-1) + " " + str(b)) print str(a-1) + " " + str(b) str(a-1) + " " str(a-1) str a-1 a 1 " " str(b) str b print(str(a) + " " + str(b-1)) print str(a) + " " + str(b-1) str(a) + " " str(a) str a " " str(b-1) str b-1 b 1 u = input() input() u s,t = input().split() input().split() s a,b = [int(x) for x in input().split()] [int(x) for x in input().split()] a t = input().split() input().split() t b = [int(x) for x in input().split()] [int(x) for x in input().split()] b
s,t = input().split()
a,b = [int(x) for x in input().split()]
u = input()
if s == u:
  print(str(a-1) + " " + str(b))
else:
  print(str(a) + " " + str(b-1))