def resolve():
    s, t = input().split()
    a, b = list(map(int, input().split()))
    u = input()

    if u == s:
        a -= 1
    elif u == t:
        b -= 1

    print(a, b)
resolve() def resolve():
    s, t = input().split()
    a, b = list(map(int, input().split()))
    u = input()

    if u == s:
        a -= 1
    elif u == t:
        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 u == s:
        a -= 1
    elif u == t:
        b -= 1

     u == s u s a -= 1 a 1 elif u == t:
        b -= 1

     u == t u t b -= 1 b 1 print(a, b) print a b resolve() resolve def resolve():
    s, t = input().split()
    a, b = list(map(int, input().split()))
    u = input()

    if u == s:
        a -= 1
    elif u == t:
        b -= 1

    print(a, b) def resolve():
    s, t = input().split()
    a, b = list(map(int, input().split()))
    u = input()

    if u == s:
        a -= 1
    elif u == t:
        b -= 1

    print(a, b) resolve
def resolve():
    s, t = input().split()
    a, b = list(map(int, input().split()))
    u = input()

    if u == s:
        a -= 1
    elif u == t:
        b -= 1

    print(a, b)
resolve()