def resolve():
    s,t = input().split()
    a,b = map(int,input().split())
    u = input()
    print(a-(s==u),b-(t==u))
resolve() def resolve():
    s,t = input().split()
    a,b = map(int,input().split())
    u = input()
    print(a-(s==u),b-(t==u)) resolve 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 print(a-(s==u),b-(t==u)) print a-(s==u) a s==u s u b-(t==u) b t==u t u resolve() resolve def resolve():
    s,t = input().split()
    a,b = map(int,input().split())
    u = input()
    print(a-(s==u),b-(t==u)) def resolve():
    s,t = input().split()
    a,b = map(int,input().split())
    u = input()
    print(a-(s==u),b-(t==u)) resolve
def resolve():
    s,t = input().split()
    a,b = map(int,input().split())
    u = input()
    print(a-(s==u),b-(t==u))
resolve()