#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using cd = complex<double>;
const int maxn = 5e5 + 10;
class dag {
  vector<vector<int>> forwards, backwards;

 public:
  dag(int n) : forwards(n), backwards(n) {}
  vector<int>& operator[](int x) { return forwards[x]; }
  vector<int>& operator()(int x) { return backwards[x]; }
  void add_edge(int x, int y) {
    forwards[x].push_back(y);
    backwards[y].push_back(x);
  }
  vector<int> mk_toposort() {
    queue<int> de_viz;
    vector<int> in_deg(forwards.size());
    for (int i = 0; i < (int)forwards.size(); ++i)
      for (auto y : forwards[i]) ++in_deg[y];
    for (int i = 0; i < (int)forwards.size(); ++i)
      if (in_deg[i] == 0) de_viz.push(i);
    vector<int> ret;
    while (!de_viz.empty()) {
      int which = de_viz.front();
      de_viz.pop();
      ret.push_back(which);
      for (auto y : forwards[which])
        if (--in_deg[y] == 0) de_viz.push(y);
    }
    return ret;
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    dag dd(n);
    vector<int> v(n);
    for (auto& x : v) cin >> x, --x;
    for (int i = n - 1; i >= 0; --i) {
      for (int j = i + 1; j < v[i]; j = (v[j] == -2 ? j + 1 : v[j]))
        dd.add_edge(j, i);
      if (v[i] < n && v[i] >= 0) dd.add_edge(i, v[i]);
    }
    auto ts = dd.mk_toposort();
    if (ts.size() != n) {
      cout << -1 << '\n';
      continue;
    }
    vector<int> ret(n);
    for (int i = 0; i < n; ++i) ret[ts[i]] = i + 1;
    for (auto x : ret) cout << x << ' ';
    cout << '\n';
  }
  return 0;
}
