import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()

    if S == U:
        A -= 1
    if T == U:
        B -= 1

    print(A, B)


if __name__ == '__main__':
    solve() import sys sys input = lambda: sys.stdin.readline().rstrip() input lambda: sys.stdin.readline().rstrip() sys.stdin.readline().rstrip() sys.stdin.readline().rstrip sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline rstrip def solve():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()

    if S == U:
        A -= 1
    if T == U:
        B -= 1

    print(A, B) solve S, T = input().split() S 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 S == U:
        A -= 1
     S == U S U A -= 1 A 1 if T == U:
        B -= 1

     T == U T U B -= 1 B 1 print(A, B) print A B if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def solve():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()

    if S == U:
        A -= 1
    if T == U:
        B -= 1

    print(A, B) def solve():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()

    if S == U:
        A -= 1
    if T == U:
        B -= 1

    print(A, B) solve input = lambda: sys.stdin.readline().rstrip() lambda: sys.stdin.readline().rstrip() input
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input()

    if S == U:
        A -= 1
    if T == U:
        B -= 1

    print(A, B)


if __name__ == '__main__':
    solve()
