#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int dfs(vector<int> &ans, vector<vector<int>> &child, int i) {
  int n = ans[i];
  for (auto &x : child[i]) {
    ans[x] = --n;
    n = dfs(ans, child, x);
  }
  return n;
}
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<vector<int>> child(n + 1);
    for (ll i = 0, iLen = (n); i < iLen; ++i) {
      cin >> a[i];
      if (a[i] != -1) {
        --a[i];
        child[a[i]].emplace_back(i);
      } else {
        child[i + 1].emplace_back(i);
      }
    }
    a[n] = n + 1;
    bool ok = 1;
    priority_queue<int> pq;
    for (ll i = 0, iLen = (n); i < iLen; ++i) {
      while (!pq.empty() && -pq.top() == i) pq.pop();
      if (a[i] != -1) {
        if (!pq.empty() && -pq.top() < a[i]) {
          ok = 0;
          break;
        }
        pq.emplace(-a[i]);
      }
    }
    if (!ok) {
      cout << -1 << "\n";
      continue;
    }
    vector<int> ans(n + 1);
    ans[n] = n + 1;
    dfs(ans, child, n);
    for (ll i = 0, iLen = (n); i < iLen; ++i) cout << ans[i] << " ";
    cout << "\n";
  }
}
