S, T = map(str, input().split())
A, H = map(int, input().split())

counter = {
    S: A,
    T: H
}

U = input()

counter[U] -= 1

print(counter[S], counter[T]) S, T = map(str, input().split()) S map(str, input().split()) map str input().split() ().split () input split T A, H = map(int, input().split()) A map(int, input().split()) map int input().split() ().split () input split H counter = {
    S: A,
    T: H
} counter {
    S: A,
    T: H
} S S A T T H U = input() U input() input counter[U] -= 1 counter[U] counter U 1 print(counter[S], counter[T]) print counter[S] counter S counter[T] counter T S, T = map(str, input().split()) map(str, input().split()) S H = map(int, input().split()) map(int, input().split()) H U = input() input() U A, H = map(int, input().split()) map(int, input().split()) A T = map(str, input().split()) map(str, input().split()) T counter = {
    S: A,
    T: H
} {
    S: A,
    T: H
} counter
S, T = map(str, input().split())
A, H = map(int, input().split())

counter = {
    S: A,
    T: H
}

U = input()

counter[U] -= 1

print(counter[S], counter[T])
