#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 1e18;
template <typename T>
void read(T &x) {
  x = 0;
  int s = 1, c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') s = -1;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  x *= s;
}
template <typename T>
void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename T>
void writeln(T x) {
  write(x);
  puts("");
}
const int maxn = 5e5 + 5;
int T, n, a[maxn], ans[maxn], C;
int dfs(int now) {
  int i = now;
  while (i > 1 && (a[i - 1] == now || a[i - 1] == -1)) i = dfs(i - 1);
  ans[now] = ++C;
  return i;
}
int main() {
  for (read(T); T--; C = 0) {
    read(n);
    for (int i = 1; i <= n; i++) read(a[i]);
    if (dfs(n + 1) > 1)
      puts("-1");
    else {
      for (int i = 1; i <= n; i++) printf("%d%c", ans[i], " \n"[i == n]);
    }
  }
  return 0;
}
