=ПРОСМОТР(9999; НАЙТИ(D2:D5; A2); E2:E5)
=INDEX(IFERROR(VLOOKUP(
ROW(A2:A25);
SPLIT(FLATTEN(IF(
REGEXMATCH(A2:A25;TRANSPOSE(B2:B25));
ROW(A2:A25) & "❤" & REGEXREPLACE(A2:A25;TRANSPOSE(B2:B25);TRANSPOSE(C2:C25));
));"❤");
2;
);A2:A25))