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