#include <bits/stdc++.h>
using namespace std;
int main(int argc, char **argv) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n, ok = 1, i = 0, cnt;
    cin >> n;
    cnt = n;
    vector<int> v(n), ans(n, -1), temp;
    vector<pair<int, int> > mat;
    for (int i = 0; i < n; i++) cin >> v[i], v[i]--;
    temp.emplace_back(n);
    while (i < n && ok) {
      if (temp.back() == i) temp.pop_back();
      if (v[i] == -2)
        v[i] = temp.back();
      else if (v[i] > temp.back())
        ok = 0;
      else if (v[i] < temp.back())
        temp.emplace_back(v[i]);
      mat.emplace_back(v[i], i), i++;
    }
    if (!ok) {
      cout << -1 << "\n";
      continue;
    }
    sort(mat.begin(), mat.end(), [](pair<int, int> l, pair<int, int> r) {
      if (l.first == r.first) return l.second < r.second;
      return l.first > r.first;
    });
    for (auto x : mat) ans[x.second] = cnt--;
    for (auto x : ans) cout << x << " ";
    cout << "\n";
  }
}
