#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<vector<int>> v(n + 2);
    vector<int> p(n);
    set<int> s;
    for (int i = 0; i < n; i++) {
      cin >> p[i];
      if (p[i] == -1) {
        while (!s.empty() && *s.begin() <= i + 1) s.erase(*s.begin());
        if (s.empty())
          p[i] = n + 1;
        else
          p[i] = *s.begin();
      } else
        s.insert(p[i]);
    }
    for (int i = 0; i < n; i++) v[p[i]].push_back(i);
    int k = n;
    vector<int> res(n + 1);
    for (int i = n + 1; i >= 0; i--) {
      for (int j = 0; j < v[i].size(); j++) res[v[i][j]] = k--;
    }
    stack<pair<int, int>> st;
    int f = 0;
    for (int i = n - 1; i >= 0; i--) {
      while (!st.empty() && st.top().first <= res[i]) st.pop();
      if (st.empty()) {
        if (p[i] != n + 1) {
          f = 1;
          break;
        }
      } else {
        if (p[i] != st.top().second) {
          f = 1;
          break;
        }
      }
      st.push({res[i], i + 1});
    }
    if (f == 1) {
      cout << -1 << endl;
      continue;
    }
    for (int i = 0; i < n; i++) cout << res[i] << " ";
    cout << endl;
  }
  return 0;
}
