#include <bits/stdc++.h>
using namespace std;
vector<long long> adj[500005];
long long nex[500005];
long long perm[500005];
long long av;
void dfs(long long i) {
  perm[i] = av;
  av--;
  for (auto j : adj[i]) {
    dfs(j);
  }
}
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    bool flag = true;
    av = n;
    for (long long i = 1; i < n + 1; i++) {
      adj[i].clear();
      perm[i] = 0;
    }
    for (long long i = 1; i < n + 1; i++) {
      cin >> nex[i];
      if (nex[i] == -1) {
        continue;
      }
      adj[nex[i]].push_back(i);
    }
    stack<long long> s;
    for (long long i = 1; i < n + 1; i++) {
      if (nex[i] == -1) {
        continue;
      }
      if (s.empty()) {
        s.push(nex[i]);
        continue;
      }
      while (i >= s.top()) {
        s.pop();
        if (s.empty()) {
          break;
        }
      }
      if (s.empty()) {
        s.push(nex[i]);
        continue;
      }
      long long v = s.top();
      long long vv = nex[i];
      if (vv > v) {
        flag = false;
        break;
      }
      s.push(nex[i]);
    }
    if (!flag) {
      cout << -1 << endl;
      continue;
    }
    for (long long i = 1; i < n + 1; i++) {
      if (nex[i] == n + 1) {
        dfs(i);
      }
    }
    for (long long i = 1; i < n + 1; i++) {
      if (perm[i] != 0) {
        continue;
      }
      long long z = i;
      while (nex[z] != -1) {
        z = nex[z];
      }
      dfs(z);
    }
    for (long long i = 1; i < n + 1; i++) {
      cout << perm[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
