#include <bits/stdc++.h>
using namespace std;
void dfs(int node, vector<vector<int> > &adj, vector<int> &ans, int &ptr) {
  ans[node] = ptr;
  for (int v : adj[node]) {
    ptr--;
    dfs(v, adj, ans, ptr);
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int next[n + 1];
    for (int i = 1; i <= n; i++) {
      cin >> next[i];
      if (next[i] == -1) next[i] = i + 1;
    }
    multiset<int> mst;
    bool possible = true;
    for (int i = 1; i <= n; i++) {
      auto it = mst.lower_bound(next[i]);
      if (it != mst.begin() and (*(--it)) > i) {
        possible = false;
      }
      mst.insert(next[i]);
    }
    if (!possible) {
      cout << -1 << endl;
    } else {
      vector<vector<int> > adj(n + 2);
      for (int i = 1; i <= n; i++) {
        adj[next[i]].push_back(i);
      }
      vector<int> ans(n + 2, 0);
      int ptr = n + 1;
      dfs(n + 1, adj, ans, ptr);
      for (int i = 1; i <= n; i++) cout << ans[i] << " ";
      cout << endl;
    }
  }
}
