x = input().split()
y = input().split()
z = input()
if x[0] == z:
  y[0] = int(y[0]) - 1
elif x[1] == z:
  y[1] = int(y[1]) - 1
print(str(y[0])+' '+str(y[1])) x = input().split() x input().split() ().split () input split y = input().split() y input().split() ().split () input split z = input() z input() input if x[0] == z:
  y[0] = int(y[0]) - 1
elif x[1] == z:
  y[1] = int(y[1]) - 1 x[0] == z x[0] x 0 z y[0] = int(y[0]) - 1 y[0] y 0 int(y[0]) - 1 int(y[0]) int y[0] y 0 1 elif x[1] == z:
  y[1] = int(y[1]) - 1 x[1] == z x[1] x 1 z y[1] = int(y[1]) - 1 y[1] y 1 int(y[1]) - 1 int(y[1]) int y[1] y 1 1 print(str(y[0])+' '+str(y[1])) print str(y[0])+' '+str(y[1]) str(y[0])+' ' str(y[0]) str y[0] y 0 ' ' str(y[1]) str y[1] y 1 x = input().split() input().split() x y = input().split() input().split() y z = input() input() z
x = input().split()
y = input().split()
z = input()
if x[0] == z:
  y[0] = int(y[0]) - 1
elif x[1] == z:
  y[1] = int(y[1]) - 1
print(str(y[0])+' '+str(y[1]))