Can you please upload a sample sheet with required output.
brief idea is to use
=If(first_condition,1,snd_condition,2,thrd_condition,3,4) and put condition formatting using like
=If(first_condition,1,snd_condition,2,thrd_condition,3,4) =1 then red color condition...