#include <bits/stdc++.h>
using namespace std;
int T, N;
int b[500005], a[500005];
vector<int> adj[500005];
int ind[500005];
map<int, int> mp;
map<int, int>::iterator p, p1;
void work() {
  for (int i = 1; i <= N; i++) {
    p = mp.upper_bound(i);
    if (p != mp.end()) {
      adj[i].push_back(p->second);
      ++ind[p->second];
    }
    if (b[i] != -1) {
      adj[i].push_back(b[i]);
      ind[b[i]]++;
      p = mp.upper_bound(b[i]);
      for (p1 = mp.begin(); p1 != p;) {
        if (p1->first <= b[i])
          mp.erase(p1++);
        else
          break;
      }
      mp[b[i]] = i;
    }
  }
  queue<int> q;
  int tt = 0;
  for (int i = 1; i <= N; i++) {
    if (ind[i] == 0) q.push(i);
  }
  int u, v;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    if (u > N) continue;
    a[u] = ++tt;
    for (int k = 0; k < adj[u].size(); k++) {
      v = adj[u][k];
      --ind[v];
      if (ind[v] == 0) q.push(v);
    }
  }
  if (tt < N) {
    puts("-1");
    return;
  }
  for (int i = 1; i <= N; i++) printf("%d ", a[i]);
  puts("");
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &N);
    for (int i = 1; i <= N + 1; i++) {
      adj[i].clear();
      ind[i] = a[i] = 0;
    }
    mp.clear();
    for (int i = 1; i <= N; i++) scanf("%d", &b[i]);
    work();
  }
  return 0;
}
