#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
void solve(int N, vec<int>& P) {
  vvec<int> g(N + 1);
  map<int, int> mr;
  for (int i = 0; i < N; i++) {
    map<int, int>::iterator it = mr.upper_bound(i);
    if (it != mr.end()) g[it->second].push_back(i);
    if (P[i] != -1) {
      g[P[i]].push_back(i);
      mr[P[i]] = i;
    }
    if (mr.count(i)) mr.erase(i);
  }
  vec<int> indeg(N + 1, 0);
  for (int i = 0; i < N; i++)
    for (auto& e : g[i]) indeg[e]++;
  vec<int> ans(N, -1);
  queue<int> Q;
  for (int i = 0; i < N; i++)
    if (!indeg[i]) Q.push(i);
  int now = N;
  while (!Q.empty()) {
    int cur = Q.front();
    Q.pop();
    ans[cur] = now--;
    for (auto& e : g[cur]) {
      indeg[e]--;
      assert(indeg[e] >= 0);
      if (!indeg[e]) Q.push(e);
    }
  }
  for (int i = 0; i < N; i++)
    if (ans[i] == -1) {
      cout << -1 << "\n";
      return;
    }
  for (int i = 0; i < N; i++) cout << ans[i] << (i != N - 1 ? " " : "\n");
  return;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  for (int t = 0; t < T; t++) {
    int N;
    cin >> N;
    vec<int> P(N);
    for (int i = 0; i < N; i++) {
      cin >> P[i];
      if (P[i] != -1) P[i]--;
    }
    solve(N, P);
  }
}
