//stl vector的应用!
code:
#include<iostream>
#include<vector>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int i,j,n,lp[50],ans[50];
cin>>n;
for(i=1;i<=n;i++) cin>>lp[i];
vector<int>temp;
for(i=1;i<=lp[1];i++) temp.push_back(lp[1]-i+1);
//temp.pop_back();
//for(i=0;i<temp.size();i++) cout<<temp[i]<<" ";
//cout<<temp[temp.size()-1]<<endl;
for(i=1;i<=n;i++)
{
if(i==1 || lp[i]==lp[i-1])
{
ans[i]=temp[temp.size()-1];
temp.pop_back();
}
else if(lp[i]>=lp[i-1]+1)
{
ans[i]=1;
for(j=0;j<temp.size();j++) temp[j]+=lp[i]-lp[i-1];
for(j=lp[i]-lp[i-1];j>=2;j--) temp.push_back(j);
}
}
for(i=1;i<=n;i++)
{
if(i!=1) cout<<" ";
cout<<ans[i];
}
cout<<endl;
}
return 0;
}