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


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


if __name__ == '__main__':
    solve()

