#include <bits/stdc++.h>
using namespace std;
const long long M = 500005;
long long n, m, a[M], t[M], ans[M], vis[M], nex[M];
set<long long> s;
signed main() {
  ios::sync_with_stdio(false);
  long long T;
  cin >> T;
  while (T--) {
    cin >> n;
    long long tot = 0;
    long long bj = 0;
    for (long long i = 1; i <= n + 1; i++) ans[i] = 0;
    for (long long i = 1; i <= n + 1; i++) vis[i] = 0;
    for (long long i = 1; i <= n; i++) cin >> a[i];
    for (long long i = 1; i <= n + 1; i++) t[i] = 0;
    for (long long i = 1; i <= n; i++) {
      if (a[i] == -1) continue;
      t[a[i]]++;
    }
    deque<long long> q;
    for (long long i = n; i >= 1; i--) {
      if (!t[i]) {
        q.push_back(i);
        vis[i] = 1;
      }
    }
    while (!q.empty()) {
      long long u = q.front();
      q.pop_front();
      ans[u] = ++tot;
      if (u == n + 1) --tot;
      t[a[u]]--;
      if (!t[a[u]])
        if (!vis[a[u]]) q.push_front(a[u]), vis[a[u]] = 1;
    }
    for (long long i = 1; i <= n; i++) {
      if (!ans[i]) {
        bj = 1;
        break;
      }
    }
    if (bj) {
      cout << -1 << "\n";
    } else {
      stack<long long> sta;
      sta.push(n + 1);
      ans[n + 1] = n + 1;
      for (long long i = n; i >= 1; i--) {
        while (ans[i] > ans[sta.top()]) sta.pop();
        nex[i] = sta.top();
        sta.push(i);
      }
      long long bbj = 0;
      for (long long i = 1; i <= n; i++) {
        if (a[i] == -1) continue;
        if (nex[i] != a[i]) bbj = 1;
      }
      if (bbj) {
        cout << -1 << "\n";
        continue;
      }
      for (long long i = 1; i <= n; i++) cout << ans[i] << ' ';
      cout << "\n";
    }
  }
  return 0;
}
