import sys

input = sys.stdin.readline


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

    if S == U:
        ans = [A - 1, B]
    else:
        ans = [A, B - 1]

    print(*ans)


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

    if S == U:
        ans = [A - 1, B]
    else:
        ans = [A, B - 1]

    print(*ans) main 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().rstrip() U input().rstrip() ().rstrip () input rstrip if S == U:
        ans = [A - 1, B]
    else:
        ans = [A, B - 1]

     S == U S U ans = [A - 1, B] ans [A - 1, B] A - 1 A 1 B ans = [A, B - 1] ans [A, B - 1] A B - 1 B 1 print(*ans) print *ans ans if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main input = sys.stdin.readline sys.stdin.readline input def main():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input().rstrip()

    if S == U:
        ans = [A - 1, B]
    else:
        ans = [A, B - 1]

    print(*ans) def main():
    S, T = input().split()
    A, B = map(int, input().split())
    U = input().rstrip()

    if S == U:
        ans = [A - 1, B]
    else:
        ans = [A, B - 1]

    print(*ans) main
import sys

input = sys.stdin.readline


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

    if S == U:
        ans = [A - 1, B]
    else:
        ans = [A, B - 1]

    print(*ans)


if __name__ == "__main__":
    main()
