#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <stack>
using namespace std;
#define debug(x) cout<<#x<<": "<<(x)<<endl;
#pragma warning(disable:4996)
bool help() {
int n;
cin >> n;
// 0( ,1)
vector<int> a;
a.reserve(50);
int lcnt = 0;
for (int i = 0; i < n; ++i) {
int lc;
cin >> lc;
while (lcnt<lc){
a.push_back(0);
++lcnt;
}
a.push_back(1);
}
stack<int>st;
for (int i = 0; i < a.size(); ++i) {
if (a[i] == 0) {
st.push(i);
}
else if(a[i]==1) {
int tp = st.top();
st.pop();
int rc = 0;
for (int j = tp; j <= i; ++j) {
if (a[j] == 1) {
++rc;
}
}
cout << rc << " ";
}
}
cout << endl;
return true;
}
int main()
{
int t;
//freopen("../in1.txt","r",stdin);
cin >> t;
for (int i = 0; i < t; ++i) {
help();
}
return 0;
}