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
        print *, a, b-1
      end if

end program main
