=LET(S,--TEXTSPLIT(TEXTJOIN(";",1,REDUCE("",A2:A30,LAMBDA(X,Y,IF(Y="",X,VSTACK(X,IF(OFFSET(Y,1,0)="",ROW(Y)-1-COUNTBLANK($A$1:Y)-SUM(X),"")))))),,";"),Z,WRAPCOLS(TOCOL(A1:C30,3,1),COUNTA(A1:A30)),REDUCE(A1:C1,S,LAMBDA(a,b,VSTACK(a,TAKE(DROP(Z,COUNT(CHOOSECOLS(a,3))+1),b),HSTACK(CONCATENATE("第",ROWS(a)-COUNT(CHOOSECOLS(a,3)),"组"),"","")))))