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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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())

# b,r = map(str, readline().split())
# A,B = map(int, readline().split())
br = LS()
AB = LI()
U = _S()

def main():
    brAB = zip(br, AB)
    tmp=[]
    for c,n in brAB:
        if c==U:
            tmp.append(n - 1)
        else:
            tmp.append(n)
    return str(tmp[0])+' '+str(tmp[1])
print(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 read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines 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())

# b,r = map(str, readline().split())
# A,B = map(int, readline().split()) LS br = LS() br LS() LS AB = LI() AB LI() LI U = _S() U _S() _S def main():
    brAB = zip(br, AB)
    tmp=[]
    for c,n in brAB:
        if c==U:
            tmp.append(n - 1)
        else:
            tmp.append(n)
    return str(tmp[0])+' '+str(tmp[1]) main brAB = zip(br, AB) brAB zip(br, AB) zip br AB tmp=[] tmp [] for c,n in brAB:
        if c==U:
            tmp.append(n - 1)
        else:
            tmp.append(n)
     c n brAB if c==U:
            tmp.append(n - 1)
        else:
            tmp.append(n)
     c==U c U tmp.append(n - 1) tmp.append tmp append n - 1 n 1 tmp.append(n) tmp.append tmp append n return str(tmp[0])+' '+str(tmp[1]) str(tmp[0])+' '+str(tmp[1]) str(tmp[0])+' ' str(tmp[0]) str tmp[0] tmp 0 ' ' str(tmp[1]) str tmp[1] tmp 1 print(main()) print main() main U = _S() _S() U def I(): return int(sys.stdin.readline().rstrip()) def I(): return int(sys.stdin.readline().rstrip()) I AB = LI() LI() AB def LS(): return list(sys.stdin.readline().rstrip().split())

# b,r = map(str, readline().split())
# A,B = map(int, readline().split()) def LS(): return list(sys.stdin.readline().rstrip().split())

# b,r = map(str, readline().split())
# A,B = map(int, readline().split()) LS br = LS() LS() br def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) LI read = sys.stdin.buffer.read sys.stdin.buffer.read read def _S(): return sys.stdin.readline().rstrip() def _S(): return sys.stdin.readline().rstrip() _S readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline def main():
    brAB = zip(br, AB)
    tmp=[]
    for c,n in brAB:
        if c==U:
            tmp.append(n - 1)
        else:
            tmp.append(n)
    return str(tmp[0])+' '+str(tmp[1]) def main():
    brAB = zip(br, AB)
    tmp=[]
    for c,n in brAB:
        if c==U:
            tmp.append(n - 1)
        else:
            tmp.append(n)
    return str(tmp[0])+' '+str(tmp[1]) main
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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())

# b,r = map(str, readline().split())
# A,B = map(int, readline().split())
br = LS()
AB = LI()
U = _S()

def main():
    brAB = zip(br, AB)
    tmp=[]
    for c,n in brAB:
        if c==U:
            tmp.append(n - 1)
        else:
            tmp.append(n)
    return str(tmp[0])+' '+str(tmp[1])
print(main())
