s1, s2 = input().split()

a, b = list(map(int, input().split()))

s3 = eval(input())



if s1==s3:

  print((a-1, ' ', b))

elif s2==s3:

  print((a, ' ', b-1))
s,t = input().split()

a,b = list(map(int,input().split()))

u = eval(input())

if u==s:

  a -= 1

else:

  b -= 1

print((a,' ',b))

s1, s2 = input().split()
a, b = list(map(int, input().split()))
s3 = eval(input())
if s1 == s3:
    print((a - 1, " ", b))
elif s2 == s3:
    print((a, " ", b - 1))

s, t = input().split()
a, b = list(map(int, input().split()))
u = eval(input())
if u == s:
    a -= 1
else:
    b -= 1
print((a, " ", b))

-s1, s2 = input().split() +s, t = input().split() -s3 = eval(input()) -if s1 == s3: -    print((a - 1, " ", b)) -elif s2 == s3: -    print((a, " ", b - 1)) +u = eval(input()) +if u == s: +    a -= 1 +else: +    b -= 1 +print((a, " ", b))