#include <bits/stdc++.h>
const int N = 1e6 + 5, inf = 1e9 + 7;
using namespace std;
set<int> S;
int n, fa[N], e, lnk[N], nxt[N], ter[N], opt[N], a[N];
void add(int x, int y) {
  ter[++e] = y;
  nxt[e] = lnk[x];
  lnk[x] = e;
}
void Solve() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &fa[i]);
  S.clear();
  S.insert(n + 1);
  for (int i = 1; i <= n; ++i) {
    for (; (*S.begin()) <= i;) S.erase(*S.begin());
    int x = *S.begin();
    if (fa[i] != -1 && fa[i] > x) {
      puts("-1");
      return;
    }
    if (fa[i] != -1) {
      S.insert(fa[i]);
      continue;
    }
    fa[i] = x;
  }
  for (int i = 1; i <= n + 1; ++i) lnk[i] = 0;
  for (int i = 1; i <= e; ++i) nxt[i] = 0;
  e = 0;
  for (int i = n; i; --i) add(fa[i], i);
  int he = 0, ta = 1, ind = n;
  opt[1] = n + 1;
  for (; he != ta;) {
    int u = opt[++he];
    for (int i = lnk[u]; i; i = nxt[i]) {
      int v = ter[i];
      a[v] = ind--;
      opt[++ta] = v;
    }
  }
  if (ta != n + 1) {
    puts("-1");
    return;
  }
  for (int i = 1; i <= n; ++i) printf("%d ", a[i]);
  puts("");
}
int main() {
  int T;
  scanf("%d", &T);
  for (; T--;) {
    Solve();
  }
  return 0;
}
