import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S, T = readline().split()
    A, B = map(int, readline().split())
    U = readline().strip()

    if S == U:
        print(A - 1, B)
    else:
        print(A, B - 1)

    return


if __name__ == '__main__':
    main() import sys sys read = sys.stdin.read read sys.stdin.read sys.stdin sys stdin read readline = sys.stdin.readline readline sys.stdin.readline sys.stdin sys stdin readline readlines = sys.stdin.readlines readlines sys.stdin.readlines sys.stdin sys stdin readlines sys.setrecursionlimit(10 ** 9) sys.setrecursionlimit sys setrecursionlimit 10 ** 9 10 9 INF = 1 << 60 INF 1 << 60 1 60 MOD = 1000000007 MOD 1000000007 def main():
    S, T = readline().split()
    A, B = map(int, readline().split())
    U = readline().strip()

    if S == U:
        print(A - 1, B)
    else:
        print(A, B - 1)

    return main S, T = readline().split() S readline().split() ().split () readline split T A, B = map(int, readline().split()) A map(int, readline().split()) map int readline().split() ().split () readline split B U = readline().strip() U readline().strip() ().strip () readline strip if S == U:
        print(A - 1, B)
    else:
        print(A, B - 1)

     S == U S U print(A - 1, B) print A - 1 A 1 B print(A, B - 1) print A B - 1 B 1 return if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main INF = 1 << 60 1 << 60 INF MOD = 1000000007 1000000007 MOD def main():
    S, T = readline().split()
    A, B = map(int, readline().split())
    U = readline().strip()

    if S == U:
        print(A - 1, B)
    else:
        print(A, B - 1)

    return def main():
    S, T = readline().split()
    A, B = map(int, readline().split())
    U = readline().strip()

    if S == U:
        print(A - 1, B)
    else:
        print(A, B - 1)

    return main readline = sys.stdin.readline sys.stdin.readline readline readlines = sys.stdin.readlines sys.stdin.readlines readlines read = sys.stdin.read sys.stdin.read read
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S, T = readline().split()
    A, B = map(int, readline().split())
    U = readline().strip()

    if S == U:
        print(A - 1, B)
    else:
        print(A, B - 1)

    return


if __name__ == '__main__':
    main()
