#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int T, p[N], cnt, done, n;
vector<int> c[N];
bool valid;
void dfs(int u) {
  p[u] = cnt--;
  for (int v : c[u]) {
    dfs(v);
  }
  if (++done != u) {
    valid = 0;
  }
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n + 1; ++i) c[i].clear();
    valid = 1;
    for (int i = 1, x; i <= n; ++i) {
      scanf("%d", &x);
      if (x == -1) x = i + 1;
      c[x].push_back(i);
    }
    cnt = n + 1;
    done = 0;
    if (valid) dfs(n + 1);
    if (!valid) {
      puts("-1");
    } else {
      for (int i = 1; i <= n; ++i) {
        printf("%d ", p[i]);
      }
      puts("");
    }
  }
}
