#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int t;
int n, nxt[N], nxt1[N];
int lpos[N];
int pos[N];
int deg[N];
queue<int> q;
vector<int> g[N];
int p[N];
void addEdge(int v, int u) {
  deg[u]++;
  g[v].push_back(u);
}
bool check() {
  nxt1[n + 1] = n + 1;
  for (int i = n; i >= 1; i--) {
    int j = i + 1;
    while (j <= n && p[i] >= p[j]) j = nxt1[j];
    nxt1[i] = j;
  }
  for (int i = 1; i <= n; i++) {
    if (nxt[i] != i && nxt1[i] != nxt[i]) return false;
  }
  return true;
}
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &nxt[i]);
    for (int i = 1; i <= n; i++) g[i].clear();
    while (q.size() > 0) q.pop();
    for (int i = 1; i <= n; i++) deg[i] = 0;
    for (int i = 1; i <= n; i++) {
      if (nxt[i] == -1) nxt[i] = i;
    }
    for (int i = 1; i <= n + 1; i++) pos[i] = n + 1;
    for (int i = n; i >= 1; i--) {
      if (nxt[i] == i) continue;
      if (pos[nxt[i]] != n + 1) addEdge(pos[nxt[i]], i);
      pos[nxt[i]] = i;
    }
    lpos[0] = 0;
    for (int i = 1; i <= n; i++) {
      int j = i - 1;
      while (j > 0 && nxt[j] <= nxt[i]) j = lpos[j];
      lpos[i] = j;
    }
    for (int i = 1; i <= n; i++) {
      if (nxt[i] != i && nxt[i] != n + 1) addEdge(i, nxt[i]);
      if (lpos[i] != 0) addEdge(i, lpos[i]);
    }
    for (int i = 1; i <= n; i++) {
      if (deg[i] == 0) q.push(i);
    }
    bool ok = true;
    for (int i = 1; i <= n; i++) {
      if (q.empty()) {
        ok = false;
        break;
      }
      int v = q.front();
      p[v] = i;
      q.pop();
      for (int u : g[v]) {
        deg[u]--;
        if (deg[u] == 0) q.push(u);
      }
    }
    if (ok) ok &= check();
    if (ok) {
      for (int i = 1; i <= n; i++) printf("%d ", p[i]);
      printf("\n");
    } else {
      printf("%d\n", -1);
    }
  }
  return 0;
}
