program main

  implicit none
  
  character(10) :: s, t, u
  integer :: a, b
  

  read(*,*) s, t
  read(*,*) a, b
  read(*,*) u

  if( u == s ) then
    print*, a-1, b
  else if( u == t ) then
    print*, a, b-1
  else
    print*, a, b
  end if
  
end program main
