program main
    implicit none

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

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

    if (u.eq.s) then
       a=a-1
    elseif(u.eq.t) then
       b=b-1
    endif

    print *,a,b
end program main