I tried searching for this question very hard, and only managed to find one solution that sort of works. Here's the reference:
fix:
=ARRAYFORMULA(SUBSTITUTE(REGEXREPLACE(SPLIT(TRIM(FLATTEN(QUERY(QUERY(SPLIT(
FLATTEN(A3:A&"×"&TEXT(ROW(B3:H), "000000")&TEXT(COLUMN(B3:H), "000000")&"¤"&
SUBSTITUTE(B3:H, " ", "♦")), "×"),
"select max(Col2) where Col2 is not null group by Col2 pivot Col1"),,9^9))),
" ")&"", "(^. ¤)", ), "♦", " "))