z = [x for x in input().split()]
x = [int(x) for x in input().split()]
y = input()
if (y == z[0]):
      print(x[0]-1,x[1])
else:
      print(x[0], x[1]-1) x for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() x z = [x for x in input().split()] z [x for x in input().split()] 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 x = [int(x) for x in input().split()] x [int(x) for x in input().split()] y = input() y input() input if (y == z[0]):
      print(x[0]-1,x[1])
else:
      print(x[0], x[1]-1) y == z[0] y z[0] z 0 print(x[0]-1,x[1]) print x[0]-1 x[0] x 0 1 x[1] x 1 print(x[0], x[1]-1) print x[0] x 0 x[1]-1 x[1] x 1 1 z = [x for x in input().split()] [x for x in input().split()] z y = input() input() y x = [int(x) for x in input().split()] [int(x) for x in input().split()] x
z = [x for x in input().split()]
x = [int(x) for x in input().split()]
y = input()
if (y == z[0]):
      print(x[0]-1,x[1])
else:
      print(x[0], x[1]-1)
