from sys import stdin, setrecursionlimit


def main():
    input = stdin.readline
    s, t = map(str, input().split())
    a, b = map(int, input().split())
    u = input()[:-1]
    print(a - 1, b) if s == u else print(a, b - 1)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main() from sys import stdin, setrecursionlimit def main():
    input = stdin.readline
    s, t = map(str, input().split())
    a, b = map(int, input().split())
    u = input()[:-1]
    print(a - 1, b) if s == u else print(a, b - 1) main input = stdin.readline input stdin.readline stdin readline s, t = map(str, input().split()) s map(str, input().split()) map str 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()[:-1] u input()[:-1] () input :-1 -1 print(a - 1, b) if s == u 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 if __name__ == "__main__":
    setrecursionlimit(10000)
    main() __name__ == "__main__" __name__ "__main__" setrecursionlimit(10000) setrecursionlimit 10000 main() main def main():
    input = stdin.readline
    s, t = map(str, input().split())
    a, b = map(int, input().split())
    u = input()[:-1]
    print(a - 1, b) if s == u else print(a, b - 1) def main():
    input = stdin.readline
    s, t = map(str, input().split())
    a, b = map(int, input().split())
    u = input()[:-1]
    print(a - 1, b) if s == u else print(a, b - 1) main
from sys import stdin, setrecursionlimit


def main():
    input = stdin.readline
    s, t = map(str, input().split())
    a, b = map(int, input().split())
    u = input()[:-1]
    print(a - 1, b) if s == u else print(a, b - 1)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
