#include <bits/stdc++.h>
using namespace std;
int read() {
  int q = 0, w = 1;
  char ch = ' ';
  while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
  if (ch == '-') w = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') q = q * 10 + ch - '0', ch = getchar();
  return q * w;
}
const int N = 500005;
int T, n, tot, sz[N], a[N], st[N], nxt[N], true_nxt[N];
vector<int> tr[N];
void dfs1(int x) {
  sz[x] = 1;
  for (register int i = 0; i < tr[x].size(); ++i)
    dfs1(tr[x][i]), sz[x] += sz[tr[x][i]];
}
void dfs2(int x, int l, int r) {
  if (x != n + 1) a[x] = r;
  for (register int i = 0; i < tr[x].size(); ++i)
    dfs2(tr[x][i], l, l + sz[tr[x][i]] - 1), l += sz[tr[x][i]];
}
void print() {
  int top = 0;
  st[0] = n + 1;
  for (register int i = n; i >= 1; --i) {
    while (top && a[st[top]] < a[i]) --top;
    if (nxt[i] != st[top]) {
      puts("-1");
      return;
    }
    st[++top] = i;
  }
  for (register int i = 1; i <= n; ++i) printf("%d ", a[i]);
  puts("");
}
bool cmp(int x, int y) { return x > y; }
int main() {
  T = read();
  while (T--) {
    n = read();
    tot = 0;
    for (register int i = 1; i <= n + 1; ++i) tr[i].clear();
    for (register int i = 1; i <= n; ++i) {
      nxt[i] = read();
      if (nxt[i] == -1) nxt[i] = i + 1;
      tr[nxt[i]].push_back(i);
    }
    for (register int i = 1; i <= n + 1; ++i)
      sort(tr[i].begin(), tr[i].end(), cmp);
    dfs1(n + 1), dfs2(n + 1, 1, n), print();
  }
  return 0;
}
