#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10, mod = 1e9 + 7, INF = 0x3f3f3f3f;
pair<int, int> seg[maxn];
int ans[maxn];
vector<int> to[maxn];
queue<int> q;
int mn[maxn << 2], lz[maxn << 2];
void init(int l, int r, int rt) {
  mn[rt] = lz[rt] = 0;
  if (l == r) {
    seg[l].first = seg[l].second = 0;
    to[l].clear();
    return;
  }
  int m = l + r >> 1;
  init(l, m, rt << 1), init(m + 1, r, rt << 1 | 1);
}
void upd(int L, int R, int c, int l, int r, int rt) {
  if (L <= l && r <= R) {
    lz[rt] += c;
    return;
  }
  int m = l + r >> 1;
  if (L <= m) upd(L, R, c, l, m, rt << 1);
  if (R > m) upd(L, R, c, m + 1, r, rt << 1 | 1);
  mn[rt] = min(mn[rt << 1] + lz[rt << 1], mn[rt << 1 | 1] + lz[rt << 1 | 1]);
}
void qry(int add, int l, int r, int rt) {
  add += lz[rt];
  if (l == r) {
    if (mn[rt] + add == 0) q.push(l), mn[rt] = INF, lz[rt] = 0;
    return;
  }
  int m = l + r >> 1;
  if (mn[rt << 1] + lz[rt << 1] + add == 0) qry(add, l, m, rt << 1);
  if (mn[rt << 1 | 1] + lz[rt << 1 | 1] + add == 0)
    qry(add, m + 1, r, rt << 1 | 1);
  mn[rt] = min(mn[rt << 1] + lz[rt << 1], mn[rt << 1 | 1] + lz[rt << 1 | 1]);
}
bool tupo(int n) {
  qry(0, 1, n, 1);
  int id = n;
  while (int(q.size())) {
    int u = q.front();
    ans[u] = id--;
    q.pop();
    for (auto v : to[u]) upd(v, v, -1, 1, n, 1);
    if (seg[u].first) upd(seg[u].first, seg[u].second, -1, 1, n, 1);
    qry(0, 1, n, 1);
  }
  return !id;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    scanf("%d", &n);
    init(1, n, 1);
    for (int i = 1; i <= n; ++i) {
      int x;
      scanf("%d", &x);
      if (x == -1) continue;
      if (i + 1 <= x - 1)
        upd(i + 1, x - 1, 1, 1, n, 1), seg[i] = make_pair(i + 1, x - 1);
      if (x <= n) upd(i, i, 1, 1, n, 1), to[x].push_back(i);
    }
    if (tupo(n))
      for (int i = 1; i <= n; ++i) printf("%d%c", ans[i], " \n"[i == n]);
    else
      printf("-1\n");
  }
  return 0;
}
