def main():

    S, T = input().split()
    A, B = map(int, input().split())
    U = input()
    if U == S:
        return " ".join(map(str, [A-1, B]))
    else:
        return " ".join(map(str, [A, B-1]))

if __name__ == '__main__':
    print(main()) def main():

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

    S, T = input().split()
    A, B = map(int, input().split())
    U = input()
    if U == S:
        return " ".join(map(str, [A-1, B]))
    else:
        return " ".join(map(str, [A, B-1])) def main():

    S, T = input().split()
    A, B = map(int, input().split())
    U = input()
    if U == S:
        return " ".join(map(str, [A-1, B]))
    else:
        return " ".join(map(str, [A, B-1])) main
def main():

    S, T = input().split()
    A, B = map(int, input().split())
    U = input()
    if U == S:
        return " ".join(map(str, [A-1, B]))
    else:
        return " ".join(map(str, [A, B-1]))

if __name__ == '__main__':
    print(main())
