s=input().split(" ")
a,b = map(int, input().split())
u = input()
ans = "Yes"

# print((a-1,b) if (s[0]==u) else a,b-1)
if s[0]==u:
    print(a-1,b)
else:
    print(a,b-1) s=input().split(" ") s input().split(" ") ().split () input split " " a,b = map(int, input().split()) a map(int, input().split()) map int input().split() ().split () input split b u = input() u input() input ans = "Yes" ans "Yes" if s[0]==u:
    print(a-1,b)
else:
    print(a,b-1) s[0]==u s[0] s 0 u print(a-1,b) print a-1 a 1 b print(a,b-1) print a b-1 b 1 b = map(int, input().split()) map(int, input().split()) b u = input() input() u ans = "Yes" "Yes" ans s=input().split(" ") input().split(" ") s a,b = map(int, input().split()) map(int, input().split()) a
s=input().split(" ")
a,b = map(int, input().split())
u = input()
ans = "Yes"

# print((a-1,b) if (s[0]==u) else a,b-1)
if s[0]==u:
    print(a-1,b)
else:
    print(a,b-1)