#include <bits/stdc++.h>
using namespace std;
struct Data {
  int l, r;
} f[500000 + 1109];
bool cmp(const Data &A, const Data &B) {
  return A.r < B.r || (A.r == B.r && A.l > B.l);
}
stack<Data> s;
vector<int> ff[500000 + 1109];
int Now;
int n;
int a[500000 + 1109], Ans[500000 + 1109];
bool Judge() {
  while (!s.empty()) s.pop();
  for (int i = 1; i <= n; i++) {
    while (!s.empty() && (f[i].l <= s.top().l)) s.pop();
    if (s.empty())
      s.push(f[i]);
    else if (f[i].l < s.top().r)
      return false;
    else
      s.push(f[i]);
  }
  return true;
}
void DFS(int x) {
  Ans[x] = Now--;
  for (int i = 0; i < ff[x].size(); i++) DFS(ff[x][i]);
}
int main() {
  int T;
  for (scanf("%d", &T); T; T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (a[i] == -1) a[i] = i + 1;
      f[i].l = i;
      f[i].r = a[i];
      ff[i].clear();
    }
    ff[n + 1].clear();
    sort(f + 1, f + 1 + n, cmp);
    if (!Judge()) {
      printf("-1\n");
      continue;
    }
    for (int i = 1; i <= n; i++) {
      ff[a[i]].push_back(i);
    }
    Now = n + 1;
    DFS(n + 1);
    for (int i = 1; i <= n; i++) printf("%d ", Ans[i]);
    printf("\n");
  }
  return 0;
}
