#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int Next[N], Rank[N], ret[N], jump[N];
int pos;
void dfs(int node) {
  if (Next[node] != -1 && Rank[Next[node]] == 0) {
    dfs(Next[node]);
  }
  Rank[node] = pos++;
}
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &Next[i]);
  }
  for (int i = 1; i <= n + 1; ++i) {
    Rank[i] = 0;
  }
  Rank[n + 1] = 1;
  pos = 2;
  for (int i = 1; i <= n; ++i) {
    if (Rank[i] == 0 && Next[i] != -1) {
      dfs(i);
    }
  }
  for (int i = 1; i <= n; ++i) {
    if (Next[i] == -1 && Rank[i] == 0) {
      Rank[i] = pos++;
    }
  }
  for (int i = 1; i <= n; ++i) {
    ret[i] = n + 2 - Rank[i];
  }
  ret[n + 1] = n + 1;
  for (int i = n; i >= 1; --i) {
    int v = i + 1;
    while (true) {
      if (ret[i] < ret[v]) {
        break;
      }
      v = jump[v];
    }
    jump[i] = v;
    if (Next[i] != -1) {
      if (jump[i] != Next[i]) {
        printf("-1\n");
        return;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    printf("%d ", ret[i]);
  }
  putchar('\n');
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    solve();
  }
}
