as the graph I hope I could get the result like red line, just use formula in one row I try everything I could think of, but it all doesn't work
use:
=ARRAYFORMULA(SPLIT(FLATTEN(QUERY(TRANSPOSE(QUERY(QUERY(
UNIQUE({A2:B, B2:B}),
"select Col1,max(Col2)
where Col1 is not null
group by Col1
pivot Col3"),
"offset 1", 0)),,9^9)), " "))