#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f;
const int maxn = 5e5 + 10;
struct Node {
  int l, r, to, lazy, min;
} st[maxn << 3];
void pushup(int i) {
  int to = i << 1;
  if (st[to].min > st[to | 1].min) to = to | 1;
  st[i].to = to;
  st[i].min = st[to].min;
}
int get_pad(int i) { return (st[i].r - st[i].l + 1); }
void pushdown(int i) {
  int to = i << 1;
  st[to].lazy += st[i].lazy;
  st[to].min += st[i].lazy;
  to = to | 1;
  st[to].lazy += st[i].lazy;
  st[to].min += st[i].lazy;
  st[i].lazy = 0;
}
int a_l, a_r, val;
void add(int i) {
  if (a_l <= st[i].l && st[i].r <= a_r) {
    st[i].lazy += val;
    st[i].min += val;
    return;
  }
  pushdown(i);
  int mid = (st[i].r + st[i].l) >> 1;
  if (mid < a_r) add(i << 1 | 1);
  if (a_l <= mid) add(i << 1);
  pushup(i);
}
int q_i, q_min;
void querry(int i) {
  if (st[i].r == st[i].l) {
    q_i = st[i].r;
    q_min = st[i].min;
    st[i].min = inf;
    return;
  }
  pushdown(i);
  querry(st[i].to);
  pushup(i);
}
void build(int i, int l, int r) {
  st[i].l = l, st[i].r = r, st[i].to = i << 1, st[i].lazy = 0, st[i].min = 0;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build(i << 1 | 1, mid + 1, r);
  build(i << 1, l, mid);
}
int ans[maxn], cnt, len;
vector<pair<int, int> > head[maxn];
pair<int, int> temp;
void topo() {
  querry(1);
  while (q_min == 0) {
    ans[q_i] = cnt--;
    len = head[q_i].size();
    for (int i = 0; i < len; i++) {
      temp = head[q_i][i];
      a_l = temp.first, a_r = temp.second, val = -1;
      add(1);
    }
    querry(1);
  }
}
int t, n, where;
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    build(1, 1, n);
    for (int i = 1; i <= n; i++) head[i].clear();
    for (int i = 1; i <= n; i++) {
      scanf("%d", &where);
      if (where == -1) continue;
      if (where != n + 1) {
        head[where].push_back(pair<int, int>(i, i));
        a_l = i, a_r = i, val = 1;
        add(1);
      }
      a_l = i + 1, a_r = where - 1, val = 1;
      if (a_l <= a_r) {
        head[i].push_back(pair<int, int>(i + 1, where - 1));
        add(1);
      }
    }
    cnt = n;
    topo();
    if (cnt != 0)
      printf("-1\n");
    else {
      printf("%d", ans[1]);
      for (int i = 2; i <= n; i++) printf(" %d", ans[i]);
      puts("");
    }
  }
}
