An afterthought.

Try array-entering this in B2, fill down and across.

Formula: copy to clipboard
=INDEX('L1'!E$2:E$4,SMALL(IF($A2='L1'!$B$2:$D$4,ROW('L1'!$A$2:$A$4)-MIN(ROW('L1'!$A$2:$A$4))+1),COUNTIF($A$2:$A2,$A2)))

If you aren’t familiar with array-entered formulas array enter means the formula must be committed from edit mode by simultaneously pressing and holding down Ctrl and Shift while hitting Enter.