S,T=input().split()
A,B=(int(a) for a in input().split())
U = input()
if S == U :
    print(A-1,B)
else : 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 U = input() U input() input if S == U :
    print(A-1,B)
else : print(A,B-1) S == U S U print(A-1,B) print A-1 A 1 B B=(int(a) for a in input().split()) (int(a) for a in input().split()) B U = input() input() U A,B=(int(a) for a in input().split()) (int(a) for a in input().split()) A S,T=input().split() input().split() S T=input().split() input().split() T
S,T=input().split()
A,B=(int(a) for a in input().split())
U = input()
if S == U :
    print(A-1,B)
else : print(A,B-1)