#include <bits/stdc++.h>
using namespace std;
int T, N, p[500010], arr[500010], timer;
vector<int> c[500010];
void dfs(int idx) {
  arr[idx] = timer;
  timer--;
  for (auto &a : c[idx]) {
    dfs(a);
  }
}
void Solve() {
  cin >> N;
  for (int i = 0; i <= N; i++) c[i].clear();
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    p[i]--;
    if (p[i] == -2) p[i] = i + 1;
    c[p[i]].push_back(i);
  }
  timer = N;
  dfs(N);
  stack<int> s;
  for (int i = N - 1; i >= 0; i--) {
    while (!s.empty() && arr[s.top()] < arr[i]) s.pop();
    if ((s.empty() && p[i] != N) || (!s.empty() && s.top() != p[i])) {
      cout << -1 << '\n';
      return;
    }
    s.push(i);
  }
  for (int i = 0; i < N; i++) {
    cout << arr[i] + 1 << " ";
  }
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> T;
  while (T--) {
    Solve();
  }
}
