m,n = map(str,input().split())
a,b = map(int,input().split())

f = str(input())

if f == m:
  a = a -1
else:
  b = b -1 

print(str(a) + " " + str(b)) m,n = map(str,input().split()) m map(str,input().split()) map str input().split() ().split () input split n a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b f = str(input()) f str(input()) str input() input if f == m:
  a = a -1
else:
  b = b -1  f == m f m a = a -1 a a -1 a 1 b = b -1 b b -1 b 1 print(str(a) + " " + str(b)) print str(a) + " " + str(b) str(a) + " " str(a) str a " " str(b) str b a,b = map(int,input().split()) map(int,input().split()) a b = map(int,input().split()) map(int,input().split()) b m,n = map(str,input().split()) map(str,input().split()) m f = str(input()) str(input()) f a = a -1 a -1 a b = b -1 b -1 b n = map(str,input().split()) map(str,input().split()) n
m,n = map(str,input().split())
a,b = map(int,input().split())

f = str(input())

if f == m:
  a = a -1
else:
  b = b -1 

print(str(a) + " " + str(b))