def solve():
    S,T = input().split()
    A,B = [int(i) for i in input().split()]
    U = input()

    if U == S:
        print(A-1, B)
    else:
        print(A, B-1)

if __name__ == "__main__":
    solve() def solve():
    S,T = input().split()
    A,B = [int(i) for i in input().split()]
    U = input()

    if U == S:
        print(A-1, B)
    else:
        print(A, B-1) solve S,T = input().split() S input().split() ().split () input split T int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i A,B = [int(i) for i in input().split()] A [int(i) for i in input().split()] B U = input() U input() input if U == S:
        print(A-1, B)
    else:
        print(A, B-1) U == S U S print(A-1, B) print A-1 A 1 B print(A, B-1) print A B-1 B 1 if __name__ == "__main__":
    solve() __name__ == "__main__" __name__ "__main__" solve() solve def solve():
    S,T = input().split()
    A,B = [int(i) for i in input().split()]
    U = input()

    if U == S:
        print(A-1, B)
    else:
        print(A, B-1) def solve():
    S,T = input().split()
    A,B = [int(i) for i in input().split()]
    U = input()

    if U == S:
        print(A-1, B)
    else:
        print(A, B-1) solve
def solve():
    S,T = input().split()
    A,B = [int(i) for i in input().split()]
    U = input()

    if U == S:
        print(A-1, B)
    else:
        print(A, B-1)

if __name__ == "__main__":
    solve()