

def main():

    from sys import stdin, setrecursionlimit

    #from sys import stdin, setrecursionlimit

    #setrecursionlimit(10**9)

    #n = int(stdin.readline()[:-1])   

    #r = stdin.readline()[:-1]

    #r = [stdin.readline() for i in range(n)]

    #t = [int(stdin.readline()) for i in range(n)]

    #n = int(r)

    #a = r.split()

    #a,b,c = r.split()

    #a = list(map(int, r.split()))

    #a,b,c,d = map(int, r.split())

    #a = list(map(int, r.split()))

    #a = [int(s[i]) for i in range(1, n+1)]

    #a = [list(map(int, r.split())) for i in range(1,n+1)]

    #a = [list(map(int, input().split())) for i in range(1,n+1)]

    #res = 0



    s,t = input().split()

    a,b = list(map(int,input().split()))

    u = eval(input())



    if u == s:

        a-=1

    else:

        b-=1

    print((a,b))



if __name__ == '__main__':

    main()

def main():

    s,t = input().split()

    a,b = list(map(int,input().split()))

    u = eval(input())

    

    if s == u:

        print((a-1,b))

    else:

        print((a,b-1))

 

if __name__ == '__main__':

    main()

def main():
    from sys import stdin, setrecursionlimit

    # from sys import stdin, setrecursionlimit
    # setrecursionlimit(10**9)
    # n = int(stdin.readline()[:-1])
    # r = stdin.readline()[:-1]
    # r = [stdin.readline() for i in range(n)]
    # t = [int(stdin.readline()) for i in range(n)]
    # n = int(r)
    # a = r.split()
    # a,b,c = r.split()
    # a = list(map(int, r.split()))
    # a,b,c,d = map(int, r.split())
    # a = list(map(int, r.split()))
    # a = [int(s[i]) for i in range(1, n+1)]
    # a = [list(map(int, r.split())) for i in range(1,n+1)]
    # a = [list(map(int, input().split())) for i in range(1,n+1)]
    # res = 0
    s, t = input().split()
    a, b = list(map(int, input().split()))
    u = eval(input())
    if u == s:
        a -= 1
    else:
        b -= 1
    print((a, b))


if __name__ == "__main__":
    main()

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


if __name__ == "__main__":
    main()

-    from sys import stdin, setrecursionlimit - -    # from sys import stdin, setrecursionlimit -    # setrecursionlimit(10**9) -    # n = int(stdin.readline()[:-1]) -    # r = stdin.readline()[:-1] -    # r = [stdin.readline() for i in range(n)] -    # t = [int(stdin.readline()) for i in range(n)] -    # n = int(r) -    # a = r.split() -    # a,b,c = r.split() -    # a = list(map(int, r.split())) -    # a,b,c,d = map(int, r.split()) -    # a = list(map(int, r.split())) -    # a = [int(s[i]) for i in range(1, n+1)] -    # a = [list(map(int, r.split())) for i in range(1,n+1)] -    # a = [list(map(int, input().split())) for i in range(1,n+1)] -    # res = 0 -    if u == s: -        a -= 1 +    if s == u: +        print((a - 1, b)) -        b -= 1 -    print((a, b)) +        print((a, b - 1))