#include <bits/stdc++.h>
using namespace std;
int arr[500005], res[500005], nxt[500005];
int pos[500005], suf[500005];
int t[2000006];
int n;
void build() {
  for (int i = 0; i < 4 * (n + 1); i++) t[i] = n + 1;
}
void update(int v, int tl, int tr, int pos, int value) {
  if (tl > pos || tr < pos) {
    return;
  }
  if (tl == tr) {
    t[v] = value;
    return;
  }
  int tm = (tl + tr) / 2;
  update(v * 2, tl, tm, pos, value);
  update(v * 2 + 1, tm + 1, tr, pos, value);
  t[v] = min(t[v * 2], t[v * 2 + 1]);
}
int getMin(int v, int tl, int tr, int l, int r) {
  if (l > r) {
    return n + 1;
  }
  if (l == tl && r == tr) {
    return t[v];
  }
  int tm = (tl + tr) / 2;
  return min(getMin(v * 2, tl, tm, l, min(r, tm)),
             getMin(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  vector<pair<int, int> > a;
  for (int h = 0; h < tt; ++h) {
    cin >> n;
    build();
    a.clear();
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      if (arr[i] == -1) arr[i] = i + 2;
      a.emplace_back(-arr[i], i);
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
      res[a[i].second] = n - i;
    }
    for (int i = n - 1; i >= 0; i--) {
      nxt[i] = getMin(1, 0, n, res[i] + 1, n);
      update(1, 0, n, res[i], i + 1);
    }
    bool ok = true;
    for (int i = 0; i < n; i++) {
      if (arr[i] != -1 && arr[i] != nxt[i]) {
        ok = false;
        break;
      }
    }
    if (!ok) {
      cout << -1 << endl;
      continue;
    }
    for (int i = 0; i < n; i++) {
      cout << res[i] << ' ';
    }
    cout << endl;
  }
}
