# -*- coding: utf-8 -*-



str_1,str_2 = input().split()

str_1_count,str_2_count = input().split()

del_str = eval(input())

if del_str == str_1:

    str_1_count = int(str_1_count) - 1

else:

    str_2_count = int(str_2_count) - 1



print((str(str_1_count) +" " + str(str_2_count)))
ball_1,ball_2 = input().split()

ball_1_count,ball_2_count = list(map(int , input().split()))

getted_str = eval(input())

if getted_str == ball_1:

    ball_1_count -= 1

else:

    ball_2_count -= 1

print((str(ball_1_count) + " " + str(ball_2_count)))
# -*- coding: utf-8 -*-
str_1, str_2 = input().split()
str_1_count, str_2_count = input().split()
del_str = eval(input())
if del_str == str_1:
    str_1_count = int(str_1_count) - 1
else:
    str_2_count = int(str_2_count) - 1
print((str(str_1_count) + " " + str(str_2_count)))

ball_1, ball_2 = input().split()
ball_1_count, ball_2_count = list(map(int, input().split()))
getted_str = eval(input())
if getted_str == ball_1:
    ball_1_count -= 1
else:
    ball_2_count -= 1
print((str(ball_1_count) + " " + str(ball_2_count)))

-# -*- coding: utf-8 -*- -str_1, str_2 = input().split() -str_1_count, str_2_count = input().split() -del_str = eval(input()) -if del_str == str_1: -    str_1_count = int(str_1_count) - 1 +ball_1, ball_2 = input().split() +ball_1_count, ball_2_count = list(map(int, input().split())) +getted_str = eval(input()) +if getted_str == ball_1: +    ball_1_count -= 1 -    str_2_count = int(str_2_count) - 1 -print((str(str_1_count) + " " + str(str_2_count))) +    ball_2_count -= 1 +print((str(ball_1_count) + " " + str(ball_2_count)))