This is just a guess from the patterns I see in the formulas and following through with those. In L7 and filled down.
Formula: copy to clipboard
=INDEX(($D$6:$E$6,$G$6), MATCH((LARGE((D7:E7,G7),1)),INDEX((D7:E7,G7),,),0))
In N7 and filled down.
Formula: copy to clipboard
=INDEX(($D$6:$E$6,$G$6), MATCH((LARGE((D7:E7,G7),2)),INDEX((D7:E7,G7),,),0))
Are the results what you are expecting?