#include <bits/stdc++.h>
using namespace std;
inline long long fpow(long long n, long long k, int p = 998244353) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
inline long long inv(long long a, long long p = 998244353) {
  return fpow(a, p - 2, p);
}
inline long long addmod(long long a, long long val, long long p = 998244353) {
  {
    if ((a = (a + val)) >= p) a -= p;
  }
  return a;
}
inline long long submod(long long a, long long val, long long p = 998244353) {
  {
    if ((a = (a - val)) < 0) a += p;
  }
  return a;
}
inline long long mult(long long a, long long b, long long p = 998244353) {
  return (long long)a * b % p;
}
void dfs(int v, vector<int> adj[], vector<bool> &visited, int &ctr,
         vector<int> &p) {
  visited[v] = true;
  for (auto u : adj[v]) {
    if (visited[u]) continue;
    dfs(u, adj, visited, ctr, p);
  }
  if (!p[v]) p[v] = ctr--;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> p(n + 2, 0), next(n + 1);
    vector<int> pos(n + 1);
    vector<bool> hasnext(n + 1, false), visited(n + 1, false);
    vector<int> adj[n + 1];
    int ctr = n;
    for (int i = 1; i <= n; i++) {
      cin >> next[i];
      if (next[i] != -1 && next[i] != n + 1) {
        hasnext[i] = true;
        adj[i].push_back(next[i]);
      }
      if (next[i] == n + 1) {
        p[i] = ctr--;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (next[i] == -1 && !visited[i]) {
        p[i] = ctr--;
      } else if (!visited[i] && hasnext[i])
        dfs(i, adj, visited, ctr, p);
    }
    for (int i = 1; i <= n; i++) pos[p[i]] = i;
    bool check = true;
    p[n + 1] = n + 1;
    stack<int> s;
    s.push(n + 1);
    for (int i = n; i >= 1; i--) {
      while (p[s.top()] < p[i]) s.pop();
      if (next[i] != -1 && next[i] != s.top()) {
        check = false;
        break;
      }
      s.push(i);
    }
    if (check) {
      for (int i = 1; i <= n; i++) cout << p[i] << " ";
    } else
      cout << -1;
    cout << "\n";
  }
}
