import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    S,T = LS()
    A,B = LI()
    U = _S()
    print("{} {}".format(A-1,B) if U==S else "{} {}".format(A,B-1))

main()
 import bisect,collections,copy,heapq,itertools,math,numpy,string bisect collections copy heapq itertools math numpy string import sys sys sys.setrecursionlimit(10**7) sys.setrecursionlimit sys setrecursionlimit 10**7 10 7 def _S(): return sys.stdin.readline().rstrip() _S def I(): return int(sys.stdin.readline().rstrip()) I def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI def LS(): return list(sys.stdin.readline().rstrip().split()) LS def main():
    S,T = LS()
    A,B = LI()
    U = _S()
    print("{} {}".format(A-1,B) if U==S else "{} {}".format(A,B-1)) main S,T = LS() S LS() LS T A,B = LI() A LI() LI B U = _S() U _S() _S print("{} {}".format(A-1,B) if U==S else "{} {}".format(A,B-1)) print "{} {}".format(A-1,B) if U==S else "{} {}".format(A,B-1) U==S U S "{} {}".format(A-1,B) "{} {}".format "{} {}" format A-1 A 1 B "{} {}".format(A,B-1) "{} {}".format "{} {}" format A B-1 B 1 main() main def I(): return int(sys.stdin.readline().rstrip()) def I(): return int(sys.stdin.readline().rstrip()) I def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI def LS(): return list(sys.stdin.readline().rstrip().split()) def LS(): return list(sys.stdin.readline().rstrip().split()) LS def _S(): return sys.stdin.readline().rstrip() def _S(): return sys.stdin.readline().rstrip() _S def main():
    S,T = LS()
    A,B = LI()
    U = _S()
    print("{} {}".format(A-1,B) if U==S else "{} {}".format(A,B-1)) def main():
    S,T = LS()
    A,B = LI()
    U = _S()
    print("{} {}".format(A-1,B) if U==S else "{} {}".format(A,B-1)) main
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    S,T = LS()
    A,B = LI()
    U = _S()
    print("{} {}".format(A-1,B) if U==S else "{} {}".format(A,B-1))

main()

