red, blue= input().split()
r, b = [int (x) for x in input().split()]
s = input()
if s == red:
    r = r - 1
else:
    b = b - 1
print(r, end=" ")
print(b) red, blue= input().split() red input().split() ().split () input split blue 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 r, b = [int (x) for x in input().split()] r [int (x) for x in input().split()] b s = input() s input() input if s == red:
    r = r - 1
else:
    b = b - 1 s == red s red r = r - 1 r r - 1 r 1 b = b - 1 b b - 1 b 1 print(r, end=" ") print r end=" " end " " print(b) print b b = [int (x) for x in input().split()] [int (x) for x in input().split()] b s = input() input() s r = r - 1 r - 1 r red, blue= input().split() input().split() red blue= input().split() input().split() blue b = b - 1 b - 1 b r, b = [int (x) for x in input().split()] [int (x) for x in input().split()] r
red, blue= input().split()
r, b = [int (x) for x in input().split()]
s = input()
if s == red:
    r = r - 1
else:
    b = b - 1
print(r, end=" ")
print(b)
