#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vi = vector<int>;
using Pii = pair<int, int>;
int uplg(int n) { return 32 - __builtin_clz(n); }
int uplg(ll n) { return 64 - __builtin_clzll(n); }
void run();
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(18);
  run();
  return 0;
}
vector<Vi> G;
Vi post;
int cnt;
void dfs(int v) {
  if (post[v] != -1) return;
  post[v] = 0;
  for (auto& e : (G[v])) dfs(e);
  post[v] = cnt--;
}
void solve() {
  int n;
  cin >> n;
  Vi nxt(n);
  for (int i = (0); i < (n); i++) {
    cin >> nxt[i];
    if (nxt[i] > 0) nxt[i]--;
  }
  Vi tail;
  G.assign(n, {});
  for (int i = n - 1; i >= 0; i--) {
    if (nxt[i] != -1) {
      while (!tail.empty() && tail.back() < nxt[i]) {
        int j = tail.back();
        G[j].push_back(i);
        tail.pop_back();
      }
      if (nxt[i] != n) {
        if (tail.empty() || tail.back() != nxt[i]) {
          cout << "-1\n";
          return;
        }
        G[i].push_back(tail.back());
      }
    }
    tail.push_back(i);
  }
  post.assign(n, -1);
  cnt = n;
  for (int i = (0); i < (int((G).size())); i++) dfs(i);
  for (auto& k : (post)) cout << k << ' ';
  cout << '\n';
}
void run() {
  int t;
  cin >> t;
  while (t--) solve();
}
