first = input().split(" ")
second = input().split(" ")
third = input()

if third == first[0]:
    print(int(second[0])-1, second[1])
else:
    print(second[0], int(second[1])-1) first = input().split(" ") first input().split(" ") ().split () input split " " second = input().split(" ") second input().split(" ") ().split () input split " " third = input() third input() input if third == first[0]:
    print(int(second[0])-1, second[1])
else:
    print(second[0], int(second[1])-1) third == first[0] third first[0] first 0 print(int(second[0])-1, second[1]) print int(second[0])-1 int(second[0]) int second[0] second 0 1 second[1] second 1 print(second[0], int(second[1])-1) print second[0] second 0 int(second[1])-1 int(second[1]) int second[1] second 1 1 first = input().split(" ") input().split(" ") first third = input() input() third second = input().split(" ") input().split(" ") second
first = input().split(" ")
second = input().split(" ")
third = input()

if third == first[0]:
    print(int(second[0])-1, second[1])
else:
    print(second[0], int(second[1])-1)