import sys

def II(): return str(input())
def MI(): return map(int,input().split())
def MI2(): return map(str,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    S, T = MI2()
    A, B = MI()
    U = II()
    
    if U == S:
        A = A-1
    elif U == T:
        B = B-1
    
    print(A, B)

if __name__ == "__main__":
	main() import sys sys def II(): return str(input()) II def MI(): return map(int,input().split()) MI def MI2(): return map(str,input().split()) MI2 def LI(): return list(map(int,input().split())) LI def TI(): return tuple(map(int,input().split())) TI input().strip() for i in range(N) for i in range(N) i range(N) range N for i in range(N) input().strip() ().strip () input strip def RN(N): return [input().strip() for i in range(N)] RN N N def main():
    S, T = MI2()
    A, B = MI()
    U = II()
    
    if U == S:
        A = A-1
    elif U == T:
        B = B-1
    
    print(A, B) main S, T = MI2() S MI2() MI2 T A, B = MI() A MI() MI B U = II() U II() II if U == S:
        A = A-1
    elif U == T:
        B = B-1
    
     U == S U S A = A-1 A A-1 A 1 elif U == T:
        B = B-1
    
     U == T U T B = B-1 B B-1 B 1 print(A, B) print A B if __name__ == "__main__":
	main() __name__ == "__main__" __name__ "__main__" main() main def II(): return str(input()) def II(): return str(input()) II def MI(): return map(int,input().split()) def MI(): return map(int,input().split()) MI def MI2(): return map(str,input().split()) def MI2(): return map(str,input().split()) MI2 def LI(): return list(map(int,input().split())) def LI(): return list(map(int,input().split())) LI def main():
    S, T = MI2()
    A, B = MI()
    U = II()
    
    if U == S:
        A = A-1
    elif U == T:
        B = B-1
    
    print(A, B) def main():
    S, T = MI2()
    A, B = MI()
    U = II()
    
    if U == S:
        A = A-1
    elif U == T:
        B = B-1
    
    print(A, B) main def RN(N): return [input().strip() for i in range(N)] def RN(N): return [input().strip() for i in range(N)] RN def TI(): return tuple(map(int,input().split())) def TI(): return tuple(map(int,input().split())) TI
import sys

def II(): return str(input())
def MI(): return map(int,input().split())
def MI2(): return map(str,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    S, T = MI2()
    A, B = MI()
    U = II()
    
    if U == S:
        A = A-1
    elif U == T:
        B = B-1
    
    print(A, B)

if __name__ == "__main__":
	main()