#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
template <typename T, typename TT>
inline ostream &operator<<(ostream &os, const pair<T, TT> &t) {
  return os << t.first << " " << t.second;
}
template <typename T>
inline ostream &operator<<(ostream &os, const vector<T> &t) {
  for (auto i : t) os << i << " ";
  return os;
}
template <typename T>
inline istream &operator>>(istream &is, vector<T> &v) {
  for (T &t : v) is >> t;
  return is;
}
template <typename T1, typename T2>
inline istream &operator>>(istream &is, pair<T1, T2> &t) {
  is >> t.first >> t.second;
  return is;
}
const long long mod = 1e9 + 7;
void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  cin >> v;
  vector<vector<int> > g(n), lvl(n + 1);
  vector<int> s;
  for (int i = 0; i < n; i++) {
    if (v[i] != -1 and v[i] <= n) g[v[i] - 1].push_back(i);
    s.push_back(i + 1);
  }
  vector<int> dp(n), ans(n);
  for (int i = 0; i < n; i++) {
    dp[i] = 1;
    for (auto x : g[i]) dp[i] = max(dp[i], dp[x] + 1);
    if (v[i] != -1) dp[i] += v[i] - i - 2;
    lvl[dp[i]].push_back(i);
  }
  for (int i = n; i > 0; i--) {
    for (auto x : lvl[i]) {
      ans[x] = s.back();
      s.pop_back();
    }
  }
  s.clear();
  s.push_back(n + 1);
  for (int i = n - 1; i >= 0; i--) {
    while (s.back() != n + 1 and ans[i] >= ans[s.back() - 1]) s.pop_back();
    if (v[i] != -1 and v[i] != s.back()) {
      cout << -1 << '\n';
      return;
    }
    s.push_back(i + 1);
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ;
  int T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
