#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ll long long int #define pb push_back #define fr(i,n) for(int i=0;i pii; #if __cplusplus > 199711L void read(){} template void read(int& head, T&... tail) {scanf("%d",&head); read(tail...);} #define DB(args...) { cerr << __LINE__<< ": "; vector _v = split(#args, ','); err(_v.begin(), args); } vector split(const string& s, char c) { vector v;stringstream ss(s);string x; while (getline(ss, x, c)) v.push_back(x); return move(v); } void err(vector::iterator it) {cerr< void err(vector::iterator it, T a, Args... args) { cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << " "; err(++it, args...); } #else #define DB(args...) void read(int& head) {scanf("%d",&head);} #endif #define mx 51 typedef pair pii; pair a[mx]; int ans[mx]; int main(){ int t; read(t); while(t--){ int n; read(n); fr(i,n){ read(a[i].first.first); a[i].first.second=1; a[i].second=i; } bool settled=false; while(!settled){ settled=true; sort(a,a+n); int ind=0; for( ; ind < n - 1 ; ind++){ if(a[ind].first.second > 0) break; } if(ind>=n-1) break; if(a[n-1].first.first > 0){ a[n-1].first.first--; a[ind].first.second=0; settled=false; ans[a[ind].second] = a[n-1].second; } } bool allzero=true; fr(i,n) if(a[i].first.first > 0 or a[i].first.second > 0) allzero=false; if(a[n-1].first.second==1){ int sm=0; fr(i,n-1) sm+=a[i].first.first; if(sm==1) assert(false); } if(allzero){ fr(i,n) printf("%d ",ans[i]+1); printf("\n"); } else{ printf("-1\n"); } } }