#include <bits/stdc++.h>
using namespace std;
const int sh = 1e6;
const int ppr = 257;
const long long INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int N = 6e5 + 123;
const long double pi = 3.141592653589793238462643;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
vector<int> g[N];
int T, n, a[N], b[N];
int main() {
  cin >> T;
  while (T--) {
    cin >> n;
    for (int i = 1; i <= n + 1; i++) g[i].clear(), b[i] = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (a[i] == -1) a[i] = i + 1;
      g[a[i]].push_back(i);
    }
    for (int i = 1; i <= n + 1; i++) sort(g[i].begin(), g[i].end());
    queue<int> q;
    int timer = n + 1;
    q.push(n + 1);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      b[v] = timer--;
      for (auto j : g[v]) {
        if (b[j] > 0) continue;
        q.push(j);
      }
    }
    stack<int> st;
    bool ok = 1;
    for (int i = n; i >= 1; i--) {
      while (!st.empty() && b[st.top()] < b[i]) st.pop();
      if ((st.empty() && a[i] != n + 1) || (!st.empty() && a[i] != st.top())) {
        ok = 0;
        break;
      }
      st.push(i);
    }
    if (!ok) {
      cout << -1 << '\n';
      continue;
    }
    for (int i = 1; i <= n; i++) cout << b[i] << ' ';
    cout << '\n';
  }
  return 0;
}
