Try these array entered formulas* for AN4 and AO4 respectively:
Formula: copy to clipboard
=INDEX(C$3:AJ$3,MIN(IF(C4:AJ4<>"",COLUMN(C1:AJ1)))-2)
Formula: copy to clipboard
=INDEX(C$3:AJ$3,MAX(IF(C4:AJ4<>"",COLUMN(C1:AJ1)))-2)
*1) Select cell AN4,
2) Paste the first formula into the formula bar,
3) Simultaneously press the Ctrl, Shift and Enter Keys,
4) Double click to copy down.
Repeat the process for cell AO4 with the second formula.
Let us know if you have any questions.