def resolve():
    S, T = input().split()
    A, B = list(map(int, input().split()))
    U = input()
    if S == U:
        A -= 1
    else:
        B -= 1
    print(A, B)

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

if '__main__' == __name__:
    resolve()