from sys import stdin 

def main():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    if s == u:
        print(a-1, b)
    elif t == u:
        print(a, b-1)

if __name__ == "__main__":
    main() from sys import stdin def main():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    if s == u:
        print(a-1, b)
    elif t == u:
        print(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 s == u:
        print(a-1, b)
    elif t == u:
        print(a, b-1) s == u s u print(a-1, b) print a-1 a 1 b elif t == u:
        print(a, b-1) t == u t u print(a, b-1) print a b-1 b 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    if s == u:
        print(a-1, b)
    elif t == u:
        print(a, b-1) def main():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    if s == u:
        print(a-1, b)
    elif t == u:
        print(a, b-1) main
from sys import stdin 

def main():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    if s == u:
        print(a-1, b)
    elif t == u:
        print(a, b-1)

if __name__ == "__main__":
    main()