x = input().split()

s = x[0]
t = x[1]

y = input().split()

a = int(y[0])
b = int(y[1])

u = input()

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

s = x[0]
t = x[1]

y = input().split()

a = int(y[0])
b = int(y[1])

u = input()

if(u == s):
  print(a-1,b)
else:
  print(a,b-1)