#include <bits/stdc++.h>
using namespace std;
struct pont {
  vector<int> p;
};
vector<pont> g;
vector<bool> volt;
vector<int> topo;
void Topo(int akt) {
  volt[akt] = true;
  for (int i = 0; i < g[akt].p.size(); i++)
    if (!volt[g[akt].p[i]]) Topo(g[akt].p[i]);
  topo.push_back(akt);
  return;
}
int main() {
  cin.sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> v(n);
    g.assign(n, pont());
    volt.assign(n, false);
    topo.clear();
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      if (v[i] != -1) v[i]--;
    }
    deque<int> q, ind;
    bool kesz = false;
    for (int i = 0; i < n && !kesz; i++) {
      if (q.size() > 0 && q.front() == i) {
        q.pop_front();
        ind.pop_front();
      }
      if (v[i] != -1) {
        if (q.size() != 0 && v[i] > q.front()) {
          cout << "-1\n";
          kesz = true;
        } else if (q.size() == 0 || v[i] < q.front()) {
          if (v[i] < n) g[v[i]].p.push_back(i);
          q.push_front(v[i]);
          ind.push_front(i);
        } else {
          g[ind.front()].p.push_back(i);
          ind.front() = i;
        }
      } else if (q.size() > 0)
        g[ind.front()].p.push_back(i);
    }
    if (kesz) continue;
    for (int i = 0; i < n; i++)
      if (!volt[i]) Topo(i);
    reverse(topo.begin(), topo.end());
    for (int i = 0; i < n; i++) v[topo[i]] = n - i;
    for (int i = 0; i < n; i++) cout << v[i] << " ";
    cout << "\n";
  }
  return 0;
}
