#include <bits/stdc++.h>
using namespace std;
template <typename T>
ostream &operator<<(ostream &output, const vector<T> &v) {
  if (v.empty()) return output;
  for (int i = 0; i < v.size() - 1; i++) output << v[i] << " ";
  output << v.back();
  return output;
}
template <typename T>
istream &operator>>(istream &input, vector<T> &v) {
  for (auto &i : v) cin >> i;
  return input;
}
const int N = 5e5 + 10;
vector<int> g[N];
int ans[N];
int tmr;
void dfs(int v) {
  ans[v] = tmr--;
  for (auto &i : g[v]) dfs(i);
}
void __sol() {
  int n;
  cin >> n;
  for (int i = 0; i < n + 3; i++) g[i].clear();
  vector<int> p(n);
  cin >> p;
  for (int i = 1; i <= n; i++) {
    if (p[i - 1] == -1) p[i - 1] = i + 1;
    g[p[i - 1]].emplace_back(i);
  }
  tmr = n + 1;
  dfs(n + 1);
  stack<int> s;
  s.push(n + 1);
  for (int i = n; i >= 1; i--) {
    while (!s.empty() && ans[s.top()] < ans[i]) s.pop();
    if (p[i - 1] != -1 && p[i - 1] != s.top()) {
      cout << -1 << "\n";
      return;
    }
    s.push(i);
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tc = 1;
  cin >> tc;
  while (tc--) __sol();
  return 0;
}
