#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool cmp(T a, T b) {
  return a < b;
}
int n, timer;
vector<int> a(5e5 + 100), p(5e5 + 100);
vector<vector<int> > c(5e5 + 100);
void dfs(int u) {
  p[u] = timer--;
  for (int i = 0; i < c[u].size(); i++) dfs(c[u][i]);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    cin >> n;
    stack<int> q;
    for (int i = 1; i <= n + 1; i++) c[i].clear();
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (a[i] == -1) a[i] = i + 1;
      c[a[i]].push_back(i);
    }
    timer = n + 1;
    dfs(n + 1);
    bool f = 0;
    for (int i = n; i >= 1; i--) {
      while (!q.empty() && p[q.top()] < p[i]) q.pop();
      if ((q.empty() && a[i] != n + 1) || (!q.empty() && q.top() != a[i])) {
        f = 1;
        break;
      }
      q.push(i);
    }
    if (f) {
      cout << "-1\n";
      continue;
    }
    for (int i = 1; i <= n; i++) cout << p[i] << " ";
    cout << "\n";
  }
  return 0;
}
