#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const int maxn = 5e5 + 5;
const int N = 1e5 + 5, M = N * 2;
bool sa7;
int n, t, x, fen;
int nxt[maxn], a[maxn];
vector<int> idx[maxn];
int tree[1 << 20];
void build(int i, int l, int r) {
  if (l == r) {
    tree[i] = a[l + 1];
    return;
  }
  int mid = (l + r) / 2;
  build(i * 2, l, mid);
  build(i * 2 + 1, mid + 1, r);
  tree[i] = max(tree[i * 2], tree[i * 2 + 1]);
}
int GetMax(int i, int l, int r, int a, int b) {
  if (a > r || b < l) return 0;
  if (a <= l && r <= b) return tree[i];
  int mid = (l + r) / 2;
  return max(GetMax(i * 2, l, mid, a, b), GetMax(i * 2 + 1, mid + 1, r, a, b));
}
int vis[maxn], vid;
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    fen = n;
    ++vid;
    sa7 = true;
    for (int i = n + 1; i; --i) idx[i].clear();
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &x);
      a[i] = -1;
      nxt[i] = x;
      if (~x) idx[x].push_back(i), vis[i] = vid;
    }
    for (int i = 1; i <= n; ++i)
      if (~nxt[i] && vis[nxt[i]] != vid && !(~nxt[nxt[i]]))
        idx[nxt[i] + 1].push_back(nxt[i]), vis[nxt[i]] = vid;
    for (int i = n + 1; i; --i)
      for (auto j : idx[i]) a[j] = fen--;
    for (int i = n; i; --i)
      if (!(~a[i])) a[i] = fen--;
    build(1, 0, n - 1);
    for (int i = 1; i <= n && sa7; ++i)
      if (i <= nxt[i] - 2 && GetMax(1, 0, n - 1, i, nxt[i] - 2) > a[i])
        sa7 = false;
    if (!sa7) {
      puts("-1");
      continue;
    }
    for (int i = 1; i <= n; ++i) printf("%d%c", a[i], " \n"[i == n]);
  }
  return 0;
}
