#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 69;
int q;
int n;
int x;
vector<int> a[MAXN];
vector<int> h[MAXN];
int dist[MAXN];
int ans[MAXN];
set<int> s;
int md = 0;
void dfs(int x) {
  for (int i = 0; i < a[x].size(); i++) {
    int v = a[x][i];
    if (!dist[v]) {
      dist[v] = dist[x] + 1;
      h[dist[v]].push_back(v);
      md = max(md, dist[v]);
      dfs(v);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> q;
  while (q--) {
    cin >> n;
    int ok = 1;
    md = 0;
    for (int i = 1; i <= n; i++) {
      cin >> x;
      if (x == -1) {
        a[i + 1].push_back(i);
        continue;
      }
      a[x].push_back(i);
      if (!s.empty()) {
        set<int>::iterator itr = s.upper_bound(i);
        if (itr == s.end()) {
          s.insert(x);
          continue;
        }
        int u = *itr;
        if (u < x) ok = 0;
      }
      s.insert(x);
    }
    if (!ok) {
      cout << -1 << '\n';
    } else {
      dist[n + 1] = 1;
      dfs(n + 1);
      int cnt = n;
      for (int i = 2; i <= md; i++) {
        for (int j = 0; j < h[i].size(); j++) {
          int v = h[i][j];
          ans[v] = cnt--;
        }
      }
      for (int i = 1; i <= n; i++) {
        cout << ans[i] << ' ';
      }
      cout << '\n';
    }
    s.clear();
    for (int i = 1; i <= n + 1; i++) {
      a[i].clear();
      a[i].shrink_to_fit();
      h[i].clear();
      h[i].shrink_to_fit();
      dist[i] = 0;
    }
  }
}
