#include <bits/stdc++.h>
using namespace std;
clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& q) {
  in >> q.first >> q.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& q) {
  out << q.first << " " << q.second;
  return out;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2) {
  return {p1.first + p2.first, p1.second + p2.second};
}
template <typename T1, typename T2>
pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2) {
  return {p1.first - p2.first, p1.second - p2.second};
}
void solve() {
  long long n;
  cin >> n;
  long long next[n + 1], ans[n + 1];
  vector<long long> g[n + 2];
  for (long long i = 1; i <= n; i++) {
    cin >> next[i];
  }
  set<long long> s;
  s.insert(n + 1);
  for (long long i = 1; i <= n; i++) {
    if (next[i] == -1) {
      auto u = *s.lower_bound(i + 1);
      g[u].push_back(i);
    } else {
      auto u1 = *s.lower_bound(i + 1);
      auto u2 = *s.lower_bound(next[i]);
      if (u1 != u2) {
        cout << -1 << '\n';
        return;
      }
      g[next[i]].push_back(i);
      s.insert(next[i]);
    }
  }
  for (long long i = 1; i <= n + 1; i++) {
    sort((g[i]).begin(), (g[i]).end());
  }
  long long curr = n;
  queue<long long> q;
  q.push(n + 1);
  while (!q.empty()) {
    long long v = q.front();
    if (v != n + 1) ans[v] = curr, curr--;
    q.pop();
    for (auto u : g[v]) {
      q.push(u);
    }
  }
  for (long long i = 1; i <= n; i++) {
    cout << ans[i] << " ";
  }
  cout << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  start = clock();
  cout << fixed << setprecision(15);
  cin >> t;
  while (t--) {
    solve();
  }
  double time_taken = double(clock() - start) / double(CLOCKS_PER_SEC);
  cerr << time_taken;
  return 0;
}
