Help me in solving MAKEPERM problem

My issue

I want this answer

My code

#include <stdio.h>

int main(void) {
	int n;
	scanf("%d",&n);
	while(n--){
	    int t;
	    scanf("%d",&t);
	 while(t--){
	     
	 }
	}

}


Problem Link: Make Permutation Practice Coding Problem