#include <bits/stdc++.h>
using namespace std;
int fll(vector<int> &p, vector<int> &a, int l, int r, int v = 0) {
  if (l == r) return v;
  while (l < r && a[l] == -2) p[l++] = v++;
  if (l == r) return v;
  if (a[l] > r) return -1e9;
  v = fll(p, a, l + 1, a[l], v);
  if (v < 0) return v;
  p[l] = v++;
  return fll(p, a, a[l], r, v);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  ;
  while (tt--) {
    int n;
    cin >> n;
    ;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    ;
    for (__typeof(0) i = 0; i < n; i++) a[i]--;
    vector<int> p(n);
    if (fll(p, a, 0, n) < 0)
      cout << -1 << '\n';
    else
      for (__typeof(0) i = 0; i < n; i++) cout << p[i] + 1 << ' ';
    cout << '\n';
  }
  return 0;
}
