s = list(input().split())
a, b = list(map(int, input().split()))
z = input()
k = a - 1
m = b - 1
if s[0] == z:
	print(k, end=' ')
	print(b)
elif s[1] == z:
	print(a, end=' ')
	print(m) s = list(input().split()) s list(input().split()) list input().split() ().split () input split a, b = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split b z = input() z input() input k = a - 1 k a - 1 a 1 m = b - 1 m b - 1 b 1 if s[0] == z:
	print(k, end=' ')
	print(b)
elif s[1] == z:
	print(a, end=' ')
	print(m) s[0] == z s[0] s 0 z print(k, end=' ') print k end=' ' end ' ' print(b) print b elif s[1] == z:
	print(a, end=' ')
	print(m) s[1] == z s[1] s 1 z print(a, end=' ') print a end=' ' end ' ' print(m) print m k = a - 1 a - 1 k s = list(input().split()) list(input().split()) s a, b = list(map(int, input().split())) list(map(int, input().split())) a z = input() input() z m = b - 1 b - 1 m b = list(map(int, input().split())) list(map(int, input().split())) b
s = list(input().split())
a, b = list(map(int, input().split()))
z = input()
k = a - 1
m = b - 1
if s[0] == z:
	print(k, end=' ')
	print(b)
elif s[1] == z:
	print(a, end=' ')
	print(m)