#include using namespace std; typedef long long ll; #define ri register int int n,t,i,j,a[500005],ch[500005][2],k,p,ans[500005],siz[500005]; bool flag; inline int read() { char ch = getchar(); int x = 0, f = 1; while(ch < '0' || ch > '9') { if(ch == '-') f = -1; ch = getchar(); } while('0' <= ch && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } void dfs(int i,int d) { if(d>2*n) { flag=false; return; } if(!flag) return; if(d>a[p]) return; if(d==a[p]) { ch[i][0]=p; p++; } else { ch[i][0]=++k; dfs(ch[i][0],d+1); } if(d>a[p]) return; if(d==a[p]) { ch[i][1]=p; p++; } else { ch[i][1]=++k; dfs(ch[i][1],d+1); } } void dfs2(int i) { if(i<=n) { siz[i]=i; return; } if(ch[i][0]==0||ch[i][1]==0) { flag=false; return; } if(!flag) return; dfs2(ch[i][0]); dfs2(ch[i][1]); siz[i]=siz[ch[i][1]]; } void dfs3(int i) { if(i<=n) return; ans[++p]=siz[ch[i][0]]; dfs3(ch[i][0]); dfs3(ch[i][1]); } int main() { t=read(); while(t--) { n=read(); for(i=1;i<=n;i++) a[i]=read(); a[n+1]=0; p=1; k=n+1; flag=true; dfs(n+1,1); if(flag&&p==n+1) { dfs2(n+1); if(flag) { printf("Possible\n"); p=0; dfs3(n+1); for(i=1;i