s,t = input().split()
a,b = [int(a)for a in input().split()]
c = input()
if c==s:
  print(a-1,b)
elif c==t:
  print(a,b-1)   s,t = input().split() s input().split() ().split () input split t int(a)for a in input().split() for a in input().split() a input().split() ().split () input split for a in input().split() int(a) int a a,b = [int(a)for a in input().split()] a [int(a)for a in input().split()] b c = input() c input() input if c==s:
  print(a-1,b)
elif c==t:
  print(a,b-1)   c==s c s print(a-1,b) print a-1 a 1 b elif c==t:
  print(a,b-1)   c==t c t print(a,b-1) print a b-1 b 1 t = input().split() input().split() t c = input() input() c a,b = [int(a)for a in input().split()] [int(a)for a in input().split()] a s,t = input().split() input().split() s b = [int(a)for a in input().split()] [int(a)for a in input().split()] b
s,t = input().split()
a,b = [int(a)for a in input().split()]
c = input()
if c==s:
  print(a-1,b)
elif c==t:
  print(a,b-1)  