s,t = [x for x in input().split()]
a,b = [int(x) for x in input().split()]
ss = input()

if ss == s:
    print(a-1,b)
else:
    print(a,b-1) x for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() x s,t = [x for x in input().split()] s [x for x in input().split()] t int(x) for x in input().split() for x in input().split() x input().split() ().split () input split for x in input().split() int(x) int x a,b = [int(x) for x in input().split()] a [int(x) for x in input().split()] b ss = input() ss input() input if ss == s:
    print(a-1,b)
else:
    print(a,b-1) ss == s ss s print(a-1,b) print a-1 a 1 b print(a,b-1) print a b-1 b 1 s,t = [x for x in input().split()] [x for x in input().split()] s ss = input() input() ss t = [x for x in input().split()] [x for x in input().split()] t b = [int(x) for x in input().split()] [int(x) for x in input().split()] b a,b = [int(x) for x in input().split()] [int(x) for x in input().split()] a
s,t = [x for x in input().split()]
a,b = [int(x) for x in input().split()]
ss = input()

if ss == s:
    print(a-1,b)
else:
    print(a,b-1)
