Ss, Ts = input().split()
A, B = map(int, input().split())
Us = input().rstrip()

if Ss == Us:
    A -= 1
elif Ts == Us:
    B -= 1

print(A, B) Ss, Ts = input().split() Ss input().split() ().split () input split Ts A, B = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split B Us = input().rstrip() Us input().rstrip() ().rstrip () input rstrip if Ss == Us:
    A -= 1
elif Ts == Us:
    B -= 1 Ss == Us Ss Us A -= 1 A 1 elif Ts == Us:
    B -= 1 Ts == Us Ts Us 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 B -= 1 1 B Us = input().rstrip() input().rstrip() Us Ss, Ts = input().split() input().split() Ss Ts = input().split() input().split() Ts A -= 1 1 A
Ss, Ts = input().split()
A, B = map(int, input().split())
Us = input().rstrip()

if Ss == Us:
    A -= 1
elif Ts == Us:
    B -= 1

print(A, B)
