#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = v * 10 + c - '0';
  while (isdigit(c = getchar())) v = v * 10 + c - '0';
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while ((c = getchar()) == ' ')
    ;
  x = c;
}
inline void writes(string s) { puts(s.c_str()); }
inline void writeln() { writes(""); }
inline void writei(int x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline void writell(long long x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
int n, m, i, j, t, a[2000005], ans[2000005], id[2000005], fid[2000005],
    deg[2000005], cnt;
vector<int> e[2000005], seq;
void init(int x) {
  int i;
  for (((i)) = (1); ((i)) <= ((x)); ((i))++) {
    deg[i] = fid[i] = 0;
    e[i].clear();
  }
}
void add(int x, int y) {
  deg[y]++;
  e[x].push_back(y);
}
void build(int x, int l, int r) {
  if (l == r) {
    fid[id[l] = x] = l;
    return;
  }
  fid[x] = 0;
  int mid = (l + r) / 2;
  add(x, x * 2);
  add(x, x * 2 + 1);
  build(x * 2, l, mid);
  build(x * 2 + 1, mid + 1, r);
}
void update(int x, int l, int r, int ql, int qr, int c) {
  if (ql <= l && r <= qr) {
    add(c, x);
    return;
  }
  int mid = (l + r) / 2;
  if (ql <= mid) update(x * 2, l, mid, ql, qr, c);
  if (qr > mid) update(x * 2 + 1, mid + 1, r, ql, qr, c);
}
void dfs(int x) {
  seq.push_back(x);
  deg[x] = -1;
  for (__typeof((e[x]).begin()) it = (e[x]).begin(); it != (e[x]).end(); it++)
    if (!--deg[*it]) dfs(*it);
}
int main() {
  read(t);
  while (t--) {
    read(n);
    init(n * 4);
    build(1, 1, n);
    for (((i)) = (1); ((i)) <= ((n)); ((i))++) read(a[i]);
    for (((i)) = (1); ((i)) <= ((n)); ((i))++)
      if (a[i] != -1) {
        if (a[i] <= n) add(id[a[i]], id[i]);
        update(1, 1, n, i + 1, a[i] - 1, id[i]);
      }
    seq.clear();
    for (((i)) = (1); ((i)) <= ((n * 4)); ((i))++)
      if (!deg[i]) dfs(i);
    if (seq.size() < n * 4) {
      puts("-1");
      continue;
    }
    cnt = n;
    for (__typeof((seq).begin()) it = (seq).begin(); it != (seq).end(); it++)
      if (fid[*it]) ans[fid[*it]] = cnt--;
    for (((i)) = (1); ((i)) <= ((n)); ((i))++) printf("%d ", ans[i]);
    puts("");
  }
  return 0;
}
