S,T = (x for x in input().split())
A,B = map(int,input().split())
U = input()

if S == U:
    A -= 1
else:
    B -= 1

print(A,B) x for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() x S,T = (x for x in input().split()) S (x for x in input().split()) T A,B = map(int,input().split()) A map(int,input().split()) map int input().split() ().split () input split B U = input() U input() input if S == U:
    A -= 1
else:
    B -= 1 S == U S U A -= 1 A 1 B -= 1 B 1 print(A,B) print A B B = map(int,input().split()) map(int,input().split()) B A,B = map(int,input().split()) map(int,input().split()) A T = (x for x in input().split()) (x for x in input().split()) T B -= 1 1 B U = input() input() U A -= 1 1 A S,T = (x for x in input().split()) (x for x in input().split()) S
S,T = (x for x in input().split())
A,B = map(int,input().split())
U = input()

if S == U:
    A -= 1
else:
    B -= 1

print(A,B)