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


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


if S == U :
    A = A - 1
elif T == U:
    B = B - 1
    
print(A,B)
