program read
  implicit none
  character(len=10) S, T, U
  integer A, B
  read *, S, T, A, B, U
  if ( U == S ) then
  	A = A - 1
  else if ( U == T ) then
  	B = B - 1
  end if
  
  print *, A, B
end program read