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