#include <bits/stdc++.h>
using namespace std;
const int Maxn = 500005;
struct node {
  int l, r;
} Tree[4 * Maxn];
int delta, rd[5 * Maxn], val[Maxn];
vector<int> edge[5 * Maxn];
void Build(int v, int l, int r) {
  Tree[v] = {l, r};
  if (l == r) return edge[v].push_back(delta + l);
  edge[v].push_back(2 * v + 1);
  edge[v].push_back(2 * v);
  Build(2 * v, l, (l + r) / 2);
  Build(2 * v + 1, (l + r) / 2 + 1, r);
}
void AddEdge(int v, int l, int r) {
  if (r < Tree[v].l || Tree[v].r < l) return;
  if (l <= Tree[v].l && Tree[v].r <= r) return edge[delta + l - 1].push_back(v);
  AddEdge(2 * v, l, r);
  AddEdge(2 * v + 1, l, r);
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n;
    scanf("%d", &n);
    delta = 4 * (n + 1);
    for (int i = 1; i <= delta + n + 1; i++) edge[i].clear(), rd[i] = 0;
    Build(1, 1, n + 1);
    for (int i = 1; i <= n; i++) {
      int x;
      scanf("%d", &x);
      if (x == -1) continue;
      AddEdge(1, i + 1, x - 1);
      edge[x + delta].push_back(i + delta);
    }
    for (int i = 1; i <= delta + n + 1; i++)
      for (int y : edge[i]) rd[y]++;
    queue<int> Q;
    for (int i = 1; i <= delta + n + 1; i++)
      if (!rd[i]) Q.push(i);
    for (int i = 1; i <= n; i++) val[i] = -1 << 30;
    int qwq = n;
    while (Q.size()) {
      int x = Q.front();
      Q.pop();
      if (x > delta && x <= delta + n) val[x - delta] = qwq--;
      for (int y : edge[x])
        if (!--rd[y]) Q.push(y);
    }
    bool fail = false;
    for (int i = 1; i <= n; i++)
      if (val[i] == -1 << 30) fail = true;
    if (fail) {
      puts("-1");
      continue;
    }
    for (int i = 1; i <= n; i++) cout << val[i] << " \n"[i == n];
  }
  return 0;
}
