#include <bits/stdc++.h>
using namespace std;
class CPermutationRecovery {
 public:
  void solve(std::istream& cin, std::ostream& cout) {
    int t;
    cin >> t;
    while (t--) {
      int n;
      cin >> n;
      vector<int> v(n);
      for (int i = 0; i < n; i++) cin >> v[i];
      vector<int> g[n];
      int last = 0, ln = 0;
      int indg[n];
      memset(indg, 0, sizeof(int) * n);
      stack<int> st;
      for (int i = 0; i < n; i++) {
        while ((!st.empty()) && (v[st.top()] <= i)) st.pop();
        if ((!st.empty())) {
          g[i].push_back(st.top());
          indg[st.top()]++;
        }
        st.push(i);
        if (v[i] == -1 || v[i] == n + 1) continue;
        v[i]--;
        g[i].push_back(v[i]);
        indg[v[i]]++;
      }
      queue<int> q;
      for (int i = 0; i < n; i++)
        if (indg[i] == 0) q.push(i);
      vector<int> topo;
      while (!q.empty()) {
        int x = q.front();
        q.pop();
        topo.push_back(x);
        for (int y : g[x]) {
          indg[y]--;
          if (!indg[y]) q.push(y);
        }
      }
      if (topo.size() != n) {
        cout << -1 << endl;
        continue;
      } else {
        vector<int> ans(n);
        for (int i = 0; i < n; i++) ans[topo[i]] = i + 1;
        for (int i = 0; i < n; i++) cout << ans[i] << " ";
        cout << endl;
      }
    }
  }
};
int main() {
  CPermutationRecovery solver;
  std::ios::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
