#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)5e5 + 5;
int nxt[MAXN];
vector<int> g[MAXN];
struct Sparse_Table {
  vector<vector<int>> t;
  vector<int> lg, pw2;
  Sparse_Table(int n) {
    t.resize(n + 1, vector<int>(20));
    pw2.resize(20);
    lg.resize(n + 1);
    lg[1] = 0;
    for (int i = 2; i <= n; i++) {
      lg[i] = lg[i >> 1] + 1;
    }
    pw2[0] = 1;
    for (int i = 1; i < 20; i++) {
      pw2[i] = pw2[i - 1] * 2;
    }
    for (int p = 0; p < 20; p++) {
      for (int i = 1; i <= n; i++) {
        if (p == 0) {
          t[i][p] = nxt[i];
        } else if (i + pw2[p] - 1 <= n) {
          t[i][p] = max(t[i][p - 1], t[i + pw2[p - 1]][p - 1]);
        }
      }
    }
  }
  int get(int l, int r) {
    int cur = lg[r - l + 1];
    return max(t[l][cur], t[r - pw2[cur] + 1][cur]);
  }
};
int tiktak;
int ans[MAXN];
void dfs(int v) {
  ans[v] = tiktak--;
  for (int to : g[v]) {
    dfs(to);
  }
}
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n + 1; i++) {
    g[i].clear();
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &nxt[i]);
    if (nxt[i] == -1) {
      nxt[i] = i + 1;
    }
    g[nxt[i]].push_back(i);
  }
  Sparse_Table T(n);
  for (int i = 1; i <= n; i++) {
    int l = i, r = nxt[i];
    if (r - l - 1 >= 1) {
      if (T.get(l + 1, r - 1) > nxt[i]) {
        puts("-1");
        return;
      }
    }
  }
  tiktak = n + 1;
  dfs(n + 1);
  for (int i = 1; i <= n; i++) {
    printf("%d ", ans[i]);
  }
  puts("");
}
signed main() {
  int tc;
  cin >> tc;
  while (tc--) {
    solve();
  }
}
