#include <bits/stdc++.h>
using namespace std;
const int maxn = 500500;
int n, a[maxn], p[maxn], cnt;
vector<int> v[maxn];
vector<int> q;
void dfs(int x) {
  p[x] = cnt--;
  for (int i : v[x]) {
    dfs(i);
  }
}
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i <= n; i++) v[i].clear();
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      a[i]--;
      if (a[i] == -2) a[i] = i + 1;
      v[a[i]].push_back(i);
    }
    cnt = n;
    dfs(n);
    q.clear();
    for (int i = n - 1; i >= 0; i--) {
      while (!q.empty() && p[q.back()] < p[i]) {
        q.pop_back();
      }
      if ((q.empty() && a[i] != n) || (!q.empty() && q.back() != a[i])) {
        cout << "-1" << endl;
        goto lab;
      }
      q.push_back(i);
    }
    for (int i = 0; i < n; i++) cout << p[i] + 1 << " ";
    cout << endl;
  lab:;
  }
  return 0;
}
