program ABC154A
    implicit none
    character(10)::S,T,U
    integer(8)::A,B
    read(5,*)S,T,A,B,U
    if(U(1:len_trim(U))==S(1:len_trim(S)))then
        print'(i0,1x,i0)',A-1,B
    else
        print'(i0,1x,i0)',A,B-1
    end if
end program ABC154A