#include #include #include using namespace std; const int M=200010; struct point{ int dep,left,right,node; }h[M]; int cas,n,Cnt,x,lson[M],rson[M],split[M],ans[M]; void dfs(int u){ if (u<=n)return; ans[++Cnt]=split[u]; dfs(lson[u]); dfs(rson[u]); } int main(){ scanf("%d",&cas); while (cas--){ Cnt=0; scanf("%d",&n); for (int i=1;i<=n*2;i++)lson[i]=rson[i]=split[i]=0; int cnt=n,top=0; for (int i=1;i<=n;i++){ scanf("%d",&x); h[++top].dep=x; h[top].left=i; h[top].right=i; h[top].node=i; while (top>1&&h[top].dep==h[top-1].dep){ top--; h[top].dep--; cnt++; lson[cnt]=h[top].node; rson[cnt]=h[top+1].node; split[cnt]=h[top].right; h[top].node=cnt; h[top].right=h[top+1].right; } } if (top!=1||h[top].dep!=0){ puts("Impossible"); continue; } puts("Possible"); dfs(h[top].node); for (int i=1;i