#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > v;
vector<int> r;
int p[500007];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    v.clear();
    r.clear();
    int n, a;
    cin >> n;
    r = vector<int>(n + 1, 0);
    for (int i = 1; i <= n; i++) {
      cin >> a;
      p[i] = a;
      v.push_back({-a, i});
    }
    sort(v.begin(), v.end());
    int k = n;
    bool ok = 0;
    for (int i = 1; i <= n && ok == 0; i++) {
      pair<int, int> x = v[i - 1];
      if (r[x.second] == 0) {
        if (p[x.second] <= n && p[x.second] > 0)
          if (p[p[x.second]] == -1 && r[p[x.second]] == 0) {
            r[p[x.second]] = k;
            k--;
          }
        int y = x.second + 1;
        if (p[x.second] == -1) y = -1;
        while (y < p[x.second]) {
          if (p[y] == -1)
            y++;
          else
            y = p[y];
        }
        if (y == p[x.second]) {
          r[x.second] = k;
          k--;
        } else {
          ok = 1;
        }
      }
    }
    if (ok) {
      cout << (-1) << '\n';
    } else {
      for (int i = 1; i <= n; i++) cout << r[i] << " ";
      cout << ("") << '\n';
    }
  }
  return 0;
}
