Sample Input
Sample Output
I believe this could be solved using WHILE Loop but not able to figure out how to unpivot it into a single column an