#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long p[n];
    priority_queue<pair<long long, long long>> pq;
    long long psum[n];
    set<long long> s;
    long long a[n];
    for (long long i = 0; i < n; i++) a[i] = psum[i] = 0;
    for (long long i = 0; i < n; i++) {
      cin >> p[i];
      if (p[i] != -1) {
        p[i]--;
        pq.push({p[i], -i});
      } else
        psum[i]++;
      s.insert(i + 1);
    }
    for (long long i = n - 2; i >= 0; i--) psum[i] += psum[i + 1];
    long long cur = n;
    while (!pq.empty()) {
      pair<long long, long long> pa = pq.top();
      pq.pop();
      long long i = -pa.second;
      a[i] = cur--;
      if (p[i] != n) a[i] -= psum[p[i]];
      s.erase(a[i]);
    }
    for (long long i = 0; i < n; i++) {
      if (a[i] == 0) {
        a[i] = *s.begin();
        s.erase(s.begin());
      }
    }
    for (long long i = 0; i < n; i++) pq.push({a[i], i});
    s.insert(n);
    bool good = true;
    while (!pq.empty()) {
      pair<long long, long long> pa = pq.top();
      pq.pop();
      long long i = pa.second;
      if (p[i] != -1) {
        if (*s.lower_bound(i) != p[i]) {
          good = false;
          break;
        }
      }
      s.insert(i);
    }
    if (good) {
      for (long long i = 0; i < n; i++) cout << a[i] << ' ';
      cout << '\n';
    } else
      cout << "-1\n";
  }
}
