#include <bits/stdc++.h>
using namespace std;
const int maxn = 5e5 + 10;
const int inf = 0x3f3f3f3f;
int nxt[maxn];
bool vis[maxn];
int cur;
int a[maxn];
void dfs(int u) {
  if (vis[u]) return;
  vis[u] = 1;
  dfs(nxt[u]);
  a[u] = cur;
  cur--;
}
int n;
bool check() {
  static int que[maxn];
  int ql = n + 1, qr = n + 1;
  que[ql--] = n + 1;
  for (int i = n; i >= 1; i--) {
    int l = ql + 1, r = qr, ans = -1;
    while (l <= r) {
      int mid = l + r >> 1;
      if (a[que[mid]] >= a[i]) {
        ans = mid;
        r = mid - 1;
      } else {
        l = mid + 1;
      }
    }
    ans = ans[que];
    if (ans != nxt[i]) {
      return false;
    }
    while (a[que[ql + 1]] < a[i]) ql++;
    que[ql--] = i;
  }
  return true;
}
int main() {
  int TAT;
  scanf("%d", &TAT);
  for (int kase = 0; kase < TAT; kase++) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", nxt + i);
      vis[i] = 0;
      if (nxt[i] == -1) nxt[i] = i + 1;
    }
    vis[n + 1] = 1;
    cur = n;
    for (int i = 1; i <= n; i++) {
      if (!vis[i]) dfs(i);
    }
    a[n + 1] = inf;
    if (!check()) {
      puts("-1");
      continue;
    }
    for (int i = 1; i <= n; i++) {
      printf("%d%c", a[i], " \n"[i == n]);
    }
  }
  return 0;
}
