#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 10;
int A[MAXN];
int ans[MAXN];
vector<int> G[MAXN];
int cn;
void dfs(int cur) {
  for (auto nxt : G[cur]) dfs(nxt);
  ans[cur] = cn++;
}
bool my_chk(int n) {
  for (int i = 1; i <= n; i++) {
    if (ans[i] < 1 || ans[i] > n) return false;
  }
  vector<pair<int, int> > ps;
  for (int i = 1; i <= n; i++) {
    ps.push_back({ans[i], i});
  }
  sort(ps.begin(), ps.end());
  set<int> mys;
  mys.insert(n + 1);
  for (int i = n - 1; i >= 0; i--) {
    auto it = mys.upper_bound(ps[i].second);
    if ((*it) != A[ps[i].second]) return false;
    mys.insert(ps[i].second);
  }
  return true;
}
int main() {
  int T;
  scanf("%d", &T);
  int n;
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n + 1; i++) {
      ans[i] = -1;
      G[i].clear();
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d", &A[i]);
      if (A[i] != -1) {
        G[A[i]].push_back(i);
      } else {
        A[i] = i + 1;
        G[i + 1].push_back(i);
      }
    }
    for (int i = 1; i <= n + 1; i++) {
      sort(G[i].begin(), G[i].end());
      reverse(G[i].begin(), G[i].end());
    }
    cn = 1;
    dfs(n + 1);
    if (!my_chk(n)) {
      puts("-1");
      continue;
    }
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    puts("");
  }
  return 0;
}
