#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
vector<int> E[MAXN], rev[MAXN];
int n, d[MAXN], sol[MAXN];
void solve() {
  for (int i = 0; i < n + 1; ++i) {
    d[i] = 0;
    E[i].clear();
    rev[i].clear();
    sol[i] = 0;
  }
  priority_queue<int> kju;
  bool done = false;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    if (x == -1)
      x = i + 1;
    else
      x--;
    while (!kju.empty() && -kju.top() <= i) kju.pop();
    if (!kju.empty() && -kju.top() < x) done = true;
    d[x]++;
    E[i].push_back(x);
    kju.push(-x);
  }
  if (done) {
    cout << -1 << "\n";
    return;
  }
  priority_queue<pair<int, int> > Q;
  for (int i = 0; i < n; ++i)
    if (d[i] == 0) {
      Q.push(pair<int, int>(-E[i][0], i));
    }
  int cnt = 1;
  while (!Q.empty()) {
    pair<int, int> tmp = Q.top();
    Q.pop();
    int to = -tmp.first, from = tmp.second;
    if (sol[from]) continue;
    sol[from] = cnt++;
    for (auto e : E[to]) {
      d[e]--;
      if (d[e] == 0) {
        for (auto z : rev[e]) {
          if (z == to) continue;
          Q.push(pair<int, int>(-e, z));
        }
      }
      Q.push(pair<int, int>(-e, to));
    }
  }
  for (int i = 0; i < n; ++i) cout << sol[i] << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
}
