#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 7;
int n;
int nxt[N];
vector<int> g[N];
int res[N];
int cur;
bool used[N];
int nxt2[N];
void dfs(int v) {
  used[v] = true;
  for (int u : g[v]) {
    if (!used[u]) dfs(u);
  }
  res[v] = cur++;
}
void build() {
  vector<int> st;
  for (int i = 0; i < n; i++) {
    while (!st.empty() && res[st.back()] < res[i]) {
      nxt2[st.back()] = i;
      st.pop_back();
    }
    st.push_back(i);
  }
  for (int i : st) nxt2[i] = n;
}
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> nxt[i];
    if (nxt[i] != -1) nxt[i]--;
  }
  for (int i = 0; i < n; i++) g[i].clear();
  vector<int> st;
  for (int i = 0; i < n; i++) {
    while (!st.empty() && nxt[st.back()] <= i) {
      g[i].push_back(st.back());
      st.pop_back();
    }
    if (!st.empty()) g[st.back()].push_back(i);
    st.push_back(i);
  }
  for (int i = 0; i < n; i++) used[i] = false;
  cur = 0;
  for (int i = 0; i < n; i++) {
    if (!used[i]) dfs(i);
  }
  build();
  bool ok = true;
  for (int i = 0; i < n; i++) ok &= nxt[i] == -1 || nxt[i] == nxt2[i];
  if (ok) {
    for (int i = 0; i < n; i++) cout << res[i] + 1 << " ";
  } else {
    cout << "-1";
  }
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
