#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int after[500500], n, counter, order[500500];
bool possible;
vector<vector<int>> g;
void topo(int x) {
  if (x >= n) return;
  if (order[x] > 0) return;
  if (order[x] == -1) {
    possible = false;
    return;
  }
  order[x] = -1;
  for (int c : g[x]) topo(c);
  order[x] = counter--;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    counter = n;
    possible = true;
    for (ll i = (0); i < (n); ++i) {
      order[i] = 0;
      cin >> after[i];
      --after[i];
    }
    g = vector<vector<int>>(n + 1);
    for (ll i = (0); i < (n); ++i)
      if (after[i] >= 0) g[i].push_back(after[i]);
    vector<int> s;
    for (ll i = (0); i < (n); ++i) {
      while (!s.empty() && after[s.back()] <= i) s.pop_back();
      if (!s.empty()) g[i].push_back(s.back());
      if (after[i] >= 0) s.push_back(i);
    }
    vector<int> in(n + 1);
    for (ll i = (0); i < (n); ++i)
      for (int c : g[i]) ++in[c];
    for (ll i = (0); i < (n); ++i)
      if (in[i] == 0) topo(i);
    for (ll i = (0); i < (n); ++i)
      if (!order[i]) possible = false;
    if (!possible) {
      cout << -1 << endl;
    } else {
      for (ll i = (0); i < (n); ++i) {
        if (i) cout << " ";
        cout << order[i];
      }
      cout << endl;
    }
  }
  return 0;
}
