s, t = input().split()
s_num , t_num = map(int, input().split())
u = input()

if u == s:
    print(s_num-1, t_num)
else:
    print(s_num, t_num -1) s, t = input().split() s input().split() ().split () input split t s_num , t_num = map(int, input().split()) s_num map(int, input().split()) map int input().split() ().split () input split t_num u = input() u input() input if u == s:
    print(s_num-1, t_num)
else:
    print(s_num, t_num -1) u == s u s print(s_num-1, t_num) print s_num-1 s_num 1 t_num print(s_num, t_num -1) print s_num t_num -1 t_num 1 s, t = input().split() input().split() s t_num = map(int, input().split()) map(int, input().split()) t_num t = input().split() input().split() t s_num , t_num = map(int, input().split()) map(int, input().split()) s_num u = input() input() u
s, t = input().split()
s_num , t_num = map(int, input().split())
u = input()

if u == s:
    print(s_num-1, t_num)
else:
    print(s_num, t_num -1)