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

if __name__ == '__main__':
    solve() def solve():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    if u == s:
        a -= 1
    elif u == t:
        b -= 1
    print(a,b) solve 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:
        a -= 1
    elif u == t:
        b -= 1
     u == s u s a -= 1 a 1 elif u == t:
        b -= 1
     u == t u t b -= 1 b 1 print(a,b) print a b if __name__ == '__main__':
    solve() __name__ == '__main__' __name__ '__main__' solve() solve def solve():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    if u == s:
        a -= 1
    elif u == t:
        b -= 1
    print(a,b) def solve():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    if u == s:
        a -= 1
    elif u == t:
        b -= 1
    print(a,b) solve
def solve():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    if u == s:
        a -= 1
    elif u == t:
        b -= 1
    print(a,b)

if __name__ == '__main__':
    solve()
