S, T = map(str, input().split())
A, B = map(int, input().split())
U = input()

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

if U == S:
    A -= 1
    A = str(A)
    B = str(B)
    print(A+' '+B)
else :
    B -= 1
    A = str(A)
    B = str(B)
    print(A+' '+B)