#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
vector<int> v1[MAXN];
int curr;
bool ok;
int val;
int counter;
int res[MAXN];
int a[MAXN];
int ans[MAXN];
void dfs(int curr) {
  val--;
  for (int x : v1[curr]) {
    if (x == val) {
      dfs(x);
    } else {
      ok = false;
      return;
    }
  }
  ans[counter++] = curr;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    val = n + 1;
    ok = true;
    curr = 1;
    counter = 1;
    for (int i = 1; i <= n + 1; i++) {
      a[i] = 0;
      v1[i].clear();
    }
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (a[i] == -1) {
        a[i] = i + 1;
      }
    }
    for (int i = 1; i <= n; i++) {
      v1[a[i]].push_back(i);
    }
    for (int i = 1; i <= n + 1; i++) {
      sort(v1[i].begin(), v1[i].end(), greater<int>());
    }
    dfs(n + 1);
    if (!ok) {
      cout << -1 << endl;
      continue;
    }
    for (int i = 1; i <= n; i++) {
      res[ans[i]] = i;
    }
    for (int i = 1; i <= n; i++) {
      cout << res[i] << " ";
    }
    cout << endl;
  }
}
