Try:
The formula in F2:
=IFERROR(REDUCE(HSTACK("Name",SEQUENCE(,MAX(D2#))),UNIQUE(A2#),LAMBDA(a,b,LET(c,BYROW(HSTACK(C2#,D2#),LAMBDA(d,MIN(d))),e,FILTER(HSTACK(B2#,B2#&"-"&c,D2#),A2#=b),VSTACK(a,HSTACK(b,XLOOKUP(SEQUENCE(,MAX(DROP(e,,2)))-1,TAKE(e,,1),INDEX(e,,2),0,1)))))),"")
If you really happen to have 4 dynamic arrays as input with headers, then maybe 'drop' those:
=IFERROR(REDUCE(HSTACK("Name",SEQUENCE(,MAX(DROP(D1#,1)))),UNIQUE(DROP(A1#,1)),LAMBDA(a,b,LET(c,BYROW(HSTACK(DROP(C1#,1),DROP(D1#,1)),LAMBDA(d,MIN(d))),e,FILTER(HSTACK(DROP(B1#,1),DROP(B1#,1)&"-"&c,DROP(D1#,1)),DROP(A1#,1)=b),VSTACK(a,HSTACK(b,XLOOKUP(SEQUENCE(,MAX(DROP(e,,2)))-1,TAKE(e,,1),INDEX(e,,2),0,1)))))),"")
But best to ditch these prior to your original formulae.