# Vicfred
# https://atcoder.jp/contests/abc154/tasks/abc154_a
# simulation
s, t = input().split()
a, b = list(map(int, input().split()))
u = input()

balls = {}
balls[s] = a
balls[t] = b
balls[u] = balls[u] - 1

print(balls[s], balls[t])
 s, t = input().split() s input().split() ().split () input split t a, b = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split b u = input() u input() input balls = {} balls {} balls[s] = a balls[s] balls s a balls[t] = b balls[t] balls t b balls[u] = balls[u] - 1 balls[u] balls u balls[u] - 1 balls[u] balls u 1 print(balls[s], balls[t]) print balls[s] balls s balls[t] balls t s, t = input().split() input().split() s u = input() input() u b = list(map(int, input().split())) list(map(int, input().split())) b t = input().split() input().split() t a, b = list(map(int, input().split())) list(map(int, input().split())) a balls = {} {} balls
# Vicfred
# https://atcoder.jp/contests/abc154/tasks/abc154_a
# simulation
s, t = input().split()
a, b = list(map(int, input().split()))
u = input()

balls = {}
balls[s] = a
balls[t] = b
balls[u] = balls[u] - 1

print(balls[s], balls[t])

