#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
vector<int> g[maxn];
int p[maxn], nxt[maxn];
int timer;
void dfs(int s) {
  p[s] = timer--;
  for (int ch : g[s]) {
    dfs(ch);
  }
}
void test_case() {
  int n;
  cin >> n;
  for (int i = 1; i <= n + 1; i++) {
    g[i].clear();
  }
  for (int i = 1; i <= n; i++) {
    cin >> nxt[i];
    if (nxt[i] == -1) nxt[i] = i + 1;
    g[nxt[i]].push_back(i);
  }
  timer = n + 1;
  dfs(n + 1);
  stack<int> s;
  bool ok = true;
  for (int i = n, cur; i >= 1; i--) {
    while (!s.empty() && p[s.top()] < p[i]) s.pop();
    if (s.empty())
      cur = n + 1;
    else
      cur = s.top();
    s.push(i);
    if (cur != nxt[i]) ok = false;
  }
  if (!ok) {
    cout << "-1\n";
    return;
  }
  for (int i = 1; i <= n; i++) {
    cout << p[i] << " \n"[i == n];
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) test_case();
}
