#include <bits/stdc++.h>
using namespace std;
const int N = 500005;
int n, ind[N], low[N], onstack[N], last, n2, t[N];
vector<int> adj[N], st;
void go(int v) {
  ind[v] = low[v] = ++last;
  st.push_back(v);
  onstack[v] = 1;
  for (auto w : adj[v]) {
    if (!ind[w]) {
      go(w);
      low[v] = min(low[v], low[w]);
    } else if (onstack[w]) {
      low[v] = min(low[v], low[w]);
    }
  }
  if (low[v] == ind[v]) {
    ++n2;
    for (int w = -1; w != v;) {
      w = st.back();
      st.pop_back();
      onstack[w] = 0;
      t[w] = n2;
    }
  }
}
void scc() {
  last = n2 = 0;
  st.clear();
  for (auto i = (0); i <= ((n)-1); ++i) ind[i] = onstack[i] = t[i] = low[i] = 0;
  for (auto i = (0); i <= ((n)-1); ++i)
    if (!ind[i]) go(i);
  for (auto i = (0); i <= ((n)-1); ++i) t[i] = n2 + 1 - t[i];
}
bool sprawdz(vector<pair<int, int> > v) {
  set<pair<int, int> > secik;
  for (auto p : v) {
    while (true) {
      auto it = secik.lower_bound({p.first, 0});
      if (it != secik.end() && it->first < p.second) {
        if (it->second > p.second) return false;
      } else
        break;
    }
  }
  return true;
}
void jebaj() {
  cin >> n;
  vector<int> nex(n);
  vector<pair<int, int> > v;
  for (auto i = (0); i <= ((n)-1); ++i) {
    cin >> nex[i];
    if (nex[i] != -1) v.emplace_back(i, nex[i] - 1);
  }
  sort((v).begin(), (v).end(),
       [](const pair<int, int>& a, const pair<int, int>& b) {
         return a.second - a.first < b.second - b.first;
       });
  if (!sprawdz(v)) {
    cout << "-1\n";
    return;
  }
  set<int> starty;
  for (auto i = (0); i <= ((n)-1); ++i) starty.insert(i);
  for (auto i = (0); i <= ((n)-1); ++i) adj[i].clear();
  for (auto p : v) {
    int l = p.first, r = p.second;
    while (true) {
      auto it = starty.lower_bound(l + 1);
      if (it == starty.end()) break;
      if (*it <= l || *it >= r) break;
      adj[*it].push_back(l);
      starty.erase(it);
    }
    if (r != n) adj[l].push_back(r);
  }
  scc();
  set<int> secik;
  for (auto i = (0); i <= ((n)-1); ++i) secik.insert(t[i]);
  if ((int)((secik).size()) != n) {
    cout << "-1\n";
    return;
  }
  for (auto i = (0); i <= ((n)-1); ++i) cout << t[i] << " ";
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  while (t--) jebaj();
  return 0;
}
