def main():
  name = list(map(str,input().split()))
  num = list(map(int,input().split()))
  n = input()
  if n==name[0]:
    print(num[0]-1,num[1])
  else:
    print(num[0],num[1]-1)

main() def main():
  name = list(map(str,input().split()))
  num = list(map(int,input().split()))
  n = input()
  if n==name[0]:
    print(num[0]-1,num[1])
  else:
    print(num[0],num[1]-1) main name = list(map(str,input().split())) name list(map(str,input().split())) list map(str,input().split()) map str input().split() ().split () input split num = list(map(int,input().split())) num list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split n = input() n input() input if n==name[0]:
    print(num[0]-1,num[1])
  else:
    print(num[0],num[1]-1) n==name[0] n name[0] name 0 print(num[0]-1,num[1]) print num[0]-1 num[0] num 0 1 num[1] num 1 print(num[0],num[1]-1) print num[0] num 0 num[1]-1 num[1] num 1 1 main() main def main():
  name = list(map(str,input().split()))
  num = list(map(int,input().split()))
  n = input()
  if n==name[0]:
    print(num[0]-1,num[1])
  else:
    print(num[0],num[1]-1) def main():
  name = list(map(str,input().split()))
  num = list(map(int,input().split()))
  n = input()
  if n==name[0]:
    print(num[0]-1,num[1])
  else:
    print(num[0],num[1]-1) main
def main():
  name = list(map(str,input().split()))
  num = list(map(int,input().split()))
  n = input()
  if n==name[0]:
    print(num[0]-1,num[1])
  else:
    print(num[0],num[1]-1)

main()