import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    print(a - 1, b) if u == s else print(a, b - 1)


if __name__ == '__main__':
    resolve() import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 f_inf = float('inf') f_inf float('inf') float 'inf' mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 def resolve():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    print(a - 1, b) if u == s else print(a, b - 1) resolve s, t = input().split() s input().split() ().split () input split t a, b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b u = input() u input() input print(a - 1, b) if u == s 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__':
    resolve() __name__ == '__main__' __name__ '__main__' resolve() resolve f_inf = float('inf') float('inf') f_inf mod = 10 ** 9 + 7 10 ** 9 + 7 mod def resolve():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    print(a - 1, b) if u == s else print(a, b - 1) def resolve():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    print(a - 1, b) if u == s else print(a, b - 1) resolve
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s, t = input().split()
    a, b = map(int, input().split())
    u = input()
    print(a - 1, b) if u == s else print(a, b - 1)


if __name__ == '__main__':
    resolve()
