import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
def main():
    X = LS()
    S_ = X[0]
    T = X[1]
    A, B = MI()
    U = S()
    if U == S_:
        print(A - 1, B)
    else:
        print(A, B - 1)


if __name__ == "__main__":
    main()
 import bisect, collections, copy, heapq, itertools, math, string bisect collections copy heapq itertools math string import sys sys def I(): return int(sys.stdin.readline().rstrip()) I def MI(): return map(int, sys.stdin.readline().rstrip().split()) MI def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) LI def S(): return sys.stdin.readline().rstrip() S def LS(): return list(sys.stdin.readline().rstrip().split()) LS from  collections import defaultdict from collections import Counter import bisect bisect def main():
    X = LS()
    S_ = X[0]
    T = X[1]
    A, B = MI()
    U = S()
    if U == S_:
        print(A - 1, B)
    else:
        print(A, B - 1) main X = LS() X LS() LS S_ = X[0] S_ X[0] X 0 T = X[1] T X[1] X 1 A, B = MI() A MI() MI B U = S() U S() S if U == S_:
        print(A - 1, B)
    else:
        print(A, B - 1) U == S_ U S_ print(A - 1, B) print A - 1 A 1 B print(A, B - 1) print A B - 1 B 1 if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def S(): return sys.stdin.readline().rstrip() def S(): return sys.stdin.readline().rstrip() S def main():
    X = LS()
    S_ = X[0]
    T = X[1]
    A, B = MI()
    U = S()
    if U == S_:
        print(A - 1, B)
    else:
        print(A, B - 1) def main():
    X = LS()
    S_ = X[0]
    T = X[1]
    A, B = MI()
    U = S()
    if U == S_:
        print(A - 1, B)
    else:
        print(A, B - 1) main def MI(): return map(int, sys.stdin.readline().rstrip().split()) def MI(): return map(int, sys.stdin.readline().rstrip().split()) MI def LS(): return list(sys.stdin.readline().rstrip().split()) def LS(): return list(sys.stdin.readline().rstrip().split()) LS 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
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
def main():
    X = LS()
    S_ = X[0]
    T = X[1]
    A, B = MI()
    U = S()
    if U == S_:
        print(A - 1, B)
    else:
        print(A, B - 1)


if __name__ == "__main__":
    main()

