#include <bits/stdc++.h>
using namespace std;
int t, n, used[500005], nxt[500005], p[500005], timer;
vector<int> g[500005], mx;
void dfs(int v) {
  used[v] = 1;
  p[v] = ++timer;
  for (int i = 0; i < g[v].size(); i++) dfs(g[v][i]);
}
int main() {
  cin >> t;
  while (t--) {
    scanf("%d", &n);
    timer = 0;
    bool can = 1;
    mx.clear();
    for (int i = 1; i <= n; i++) {
      g[i].clear();
      used[i] = p[i] = 0;
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d", nxt + i);
      if (nxt[i] == n + 1) mx.push_back(i);
      if (nxt[i] != -1 && nxt[i] != n + 1) g[nxt[i]].push_back(i);
    }
    for (int i = 0; i < mx.size(); i++) dfs(mx[i]);
    for (int i = n; i >= 1; i--)
      if (!used[i]) dfs(i);
    for (int i = 1; i <= n; i++) p[i] = n + 1 - p[i];
    stack<pair<int, int>> s;
    s.push(make_pair(1000000007ll, n + 1));
    for (int i = n; i >= 1; i--) {
      while (s.top().first < p[i]) s.pop();
      if (nxt[i] != -1 && nxt[i] != s.top().second) can = 0;
      s.push(make_pair(p[i], i));
    }
    if (!can)
      printf("-1\n");
    else {
      for (int i = 1; i <= n; i++) printf("%d ", p[i]);
      printf("\n");
    }
  }
  return 0;
}
