#include <bits/stdc++.h>
using namespace std;
int n, c, a[500001], p[500001];
vector<int> adj[500001];
void dfs(int x) {
  p[x] = c;
  --c;
  for (auto i : adj[x]) dfs(i);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int i;
    cin >> n;
    for (i = 0; i < n + 1; ++i) adj[i].clear();
    for (i = 0; i < n; ++i) {
      cin >> a[i];
      --a[i];
      if (a[i] == -2) a[i] = i + 1;
      adj[a[i]].push_back(i);
    }
    c = n;
    dfs(n);
    stack<int> st;
    int next[n];
    for (i = 0; i < n; ++i) {
      while (!st.empty() && p[st.top()] < p[i]) {
        next[st.top()] = i;
        st.pop();
      }
      st.push(i);
    }
    while (!st.empty()) {
      next[st.top()] = n;
      st.pop();
    }
    int f = 1;
    for (i = 0; i < n; ++i) {
      if (a[i] != next[i]) {
        cout << "-1"
             << "\n";
        f = 0;
        break;
      }
    }
    if (f) {
      for (i = 0; i < n; ++i) cout << p[i] + 1 << " ";
      cout << "\n";
    }
  }
  return 0;
}
