s,t = input().split()
a,b = (int(x) for x in input().split())
u = input()



if u == s:
    print(a - 1,b)
else:
    print(a,b - 1)
 s,t = input().split() s input().split() ().split () 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 u = input() u input() input 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 t = input().split() 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 = input().split() input().split() s u = input() input() u
s,t = input().split()
a,b = (int(x) for x in input().split())
u = input()



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

