#include <bits/stdc++.h>
#pragma gcc optimize("O3")
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
int pp, t, n, nxt[500003], die[500003], ans[500003];
vector<int> v[500003];
void dfs(int nod) {
  reverse(v[nod].begin(), v[nod].end());
  ans[nod] = pp, --pp;
  for (int i = 0; i < v[nod].size(); ++i) {
    dfs(v[nod][i]);
  }
}
void solve() {
  deque<int> d;
  d.push_back(n + 1);
  for (int i = n; i >= 1; --i) {
    if (nxt[i] != -1) {
      if (die[nxt[i]]) {
        cout << -1 << '\n';
        return;
      }
      while (d.back() != nxt[i]) {
        die[d.back()] = 1;
        d.pop_back();
      }
    }
    v[d.back()].push_back(i);
    d.push_back(i);
  }
  pp = n + 1;
  dfs(n + 1);
  for (int i = 1; i <= n; ++i) cout << ans[i] << " ";
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> t;
  for (; t; --t) {
    cin >> n;
    for (int i = 1; i <= n; ++i) {
      cin >> nxt[i];
      v[i].clear();
      die[i] = 0;
    }
    die[n + 1] = 0;
    v[n + 1].clear();
    solve();
  }
  return 0;
}
