#include<map>
#include<unordered_map>
#include<vector>
#include<queue>
#include<cstring>
#include<math.h>
#include<algorithm>
#include<iostream>
using namespace std;
const int N = 1e5 + 10;
typedef long long LL;
int n,t;
int a[N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> t;
while (t--) {
cin >> n;
int start, end;
bool flag = false;
for (int i = 1; i <= n; i++)cin >> a[i];
for (int i = 1; i <= n; i++) {
if (a[i] == -1&&!flag)start = i,flag=true;
if (i + 1 <= n && a[i + 1] != -1 && flag) {
flag = false, end = i;
int val = (a[i + 1] - a[i - 1]) / (end - start + 2);
int yu = (a[i + 1] - a[i - 1]) % (end - start + 2);
for (int j = start; j <= end; j++) {
a[j] =a[j-1]+ val;
if (a[j] + 1 - a[j - 1] <= 1000 && yu)a[j] += 1, yu--;
}
}
if (i == n && a[i] == -1) {
for (int j = start; j <= n; j++) {
a[j] = a[j - 1] + 1;
}
}
}
for (int i = 1; i <= n; i++) {
cout << a[i] - a[i - 1] << " ";
}
cout << endl;
}
return 0;
}