program main
	implicit none
	character(10) s,t,u
	integer a,b
    
    read(*,*) s,t
    read(*,*) a,b
    read(*,*) u
    
    if(u==s) then
       write(*,'(i0,a,i0)') a-1,' ',b
    else
       write(*,'(i0,a,i0)') a,' ',b-1
    end if
end program main