#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double eps = (1e-7);
int dcmp(long double x, long double y) {
  if (abs(x - y) < eps) return 0;
  if (x > y) return 1;
  return -1;
}
int n;
bool topSort(vector<vector<int> > &adj, vector<int> &res, vector<int> &inDeg) {
  vector<bool> visit(n, 0);
  queue<int> q;
  for (int i = 0; i < n; ++i) {
    if (!inDeg[i]) {
      q.push(i);
      visit[i] = 1;
    }
  }
  int cnt = 1;
  for (int size = (int)(q).size(); !q.empty(); size = (int)(q).size()) {
    while (size--) {
      int u = q.front();
      q.pop();
      res[u] = cnt++;
      for (auto v : adj[u]) {
        --inDeg[v];
        if (!inDeg[v] && !visit[v]) {
          q.push(v);
          visit[v] = 1;
        }
      }
    }
  }
  return cnt == n + 1;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      if (a[i] != -1) --a[i];
    }
    vector<vector<int> > Pop(n);
    set<int> st;
    vector<vector<int> > adj(n);
    vector<int> inDeg(n);
    for (int i = 0; i < n; ++i) {
      while (Pop[i].size()) {
        st.erase(Pop[i].back());
        Pop[i].pop_back();
      }
      if (!st.empty()) {
        adj[i].push_back(*st.rbegin());
        inDeg[*st.rbegin()]++;
      }
      if (a[i] != -1 && a[i] != n) {
        Pop[a[i]].push_back(i);
        adj[i].push_back(a[i]);
        inDeg[a[i]]++;
      }
      if (a[i] != -1) {
        st.insert(i);
      }
    }
    vector<int> res(n);
    if (!topSort(adj, res, inDeg))
      cout << -1;
    else {
      for (int i = 0; i < n; ++i) cout << res[i] << ' ';
    }
    cout << '\n';
  }
  return 0;
}
