#include <bits/stdc++.h>
using namespace std;
const int seed = 131;
const long long LLMAX = 2e18;
const int MOD = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 1e6 + 10;
const int hmod1 = 0x48E2DCE7;
const int hmod2 = 0x60000005;
inline long long sqr(long long x) { return x * x; }
inline int sqr(int x) { return x * x; }
inline double sqr(double x) { return x * x; }
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long exgcd(long long a, long long b, long long &x, long long &y) {
  long long d;
  (b == 0 ? (x = 1, y = 0, d = a)
          : (d = exgcd(b, a % b, y, x), y -= a / b * x));
  return d;
}
long long qpow(long long a, long long n) {
  long long sum = 1;
  while (n) {
    if (n & 1) sum = sum * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return sum;
}
inline int dcmp(double x) {
  if (fabs(x) < eps) return 0;
  return (x > 0 ? 1 : -1);
}
vector<int> G[MAXN];
int a[MAXN], ans[MAXN];
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    set<int> s;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    s.insert(n + 1);
    for (int i = 1; i <= n; i++) {
      if (a[i] == -1)
        a[i] = *s.upper_bound(i);
      else
        s.insert(a[i]);
      G[a[i]].push_back(i);
    }
    int id = n;
    queue<int> q;
    q.push(n + 1);
    while (!q.empty()) {
      int u = q.front();
      q.pop();
      for (int i = 0; i < (int)G[u].size(); i++) {
        int v = G[u][i];
        ans[v] = id--;
        q.push(v);
      }
    }
    int flag = 0;
    stack<pair<int, int> > st;
    st.push(pair<int, int>(n + 1, n + 1));
    for (int i = n; i >= 1; i--) {
      while (ans[i] > st.top().first) st.pop();
      if (a[i] != st.top().second) flag = 1;
      st.push(pair<int, int>(ans[i], i));
    }
    if (!flag) {
      for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
      cout << endl;
    } else
      cout << -1 << endl;
    for (int i = 1; i <= n + 1; i++) G[i].clear();
  }
  return 0;
}
