#include using namespace std; #define ll long long const int N = 100005; int T, n, fuckbestcoder, stk[N], f[N], id[N], lson[N<<1], rson[N<<1], ans[N<<1]; void dfs(int u){ if(ans[u]){ printf("%d%c", ans[u], " \n"[++fuckbestcoder==n-1]); dfs(lson[u]), dfs(rson[u]); } } int main() { scanf("%d", &T); while(T--){ scanf("%d", &n); int cnt=0, top=0; for(int i=1; i<=n; ++i){ scanf("%d", ++top+stk); f[top]=i, id[top]=++cnt; while(top>1 && stk[top]==stk[top-1]){ ++cnt; lson[cnt]=id[top-1], rson[cnt]=id[top], ans[cnt]=f[top-1]; --stk[--top], f[top]=i, id[top]=cnt; } } if(top==1 && !stk[top]){ puts("Possible"); fuckbestcoder=0; dfs(cnt); } else puts("Impossible"); memset(ans+1, 0, cnt<<2); } return 0; }