#include <bits/stdc++.h>
using namespace std;
const int MAX = 500005, oo = (1e6);
int n, ara[MAX], nex[MAX], prin[MAX], can;
void divide(int st, int en, int lv, int rv, int lim) {
  if (nex[st] > lim && st <= en) can = 1;
  if (st > en || can) return;
  if (nex[st] == -1) {
    ara[st] = lv;
    divide(st + 1, en, lv + 1, rv, lim);
  } else {
    int nv = (nex[st] - st), nlim = min(lim, nex[st]);
    ara[st] = lv + nv - 1;
    divide(st + 1, nex[st] - 1, lv, ara[st] - 1, nlim);
    divide(nex[st], en, ara[st] + 1, rv, lim);
  }
}
void solve(int tc) {
  can = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &nex[i]);
  divide(1, n, 1, n, oo);
  if (can)
    printf("-1\n");
  else {
    for (int i = 1; i <= n; i++) printf("%d ", ara[i]);
    printf("\n");
  }
}
int main() {
  int tc;
  scanf("%d", &tc);
  for (int tt = 1; tt <= tc; tt++) solve(tt);
  return 0;
}
