#include <bits/stdc++.h>
using namespace std;
vector<int> a[500010];
using namespace std;
long long tr[500010 * 4], lf, rt, val, b[500010];
void init(int x, int st, int nd) {
  if (st == nd) {
    tr[x] = b[st];
    return;
  }
  int md;
  md = (st + nd) / 2;
  init(x * 2, st, md);
  init(x * 2 + 1, md + 1, nd);
  tr[x] = max(tr[x * 2], tr[x * 2 + 1]);
}
long long INF = 1e9;
long long qry(int x, int st, int nd) {
  if (st > rt || nd < lf) return -INF;
  if (st >= lf && nd <= rt) return tr[x];
  int md;
  md = (st + nd) / 2;
  return max(qry(x * 2, st, md), qry(x * 2 + 1, md + 1, nd));
}
int x[500010];
int main() {
  int n, t;
  cin >> t;
  while (t--) {
    long long ans = 0;
    cin >> n;
    for (int i = 1; i <= n + 1; ++i) a[i].clear();
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &x[i]);
      if (x[i] == -1) x[i] = i + 1;
      a[x[i]].push_back(i);
    }
    int cnt = n;
    for (int i = n + 1; i >= 1; --i) {
      for (int j = 0; j < a[i].size(); ++j) {
        b[a[i][j]] = cnt--;
      }
    }
    init(1, 1, n);
    bool l = 1;
    int tmp;
    for (int i = 1; i <= n; ++i) {
      lf = i + 1;
      rt = x[i] - 1;
      tmp = qry(1, 1, n);
      if (tmp > b[i]) {
        l = 0;
        break;
      }
    }
    if (!l) {
      cout << -1 << endl;
    } else {
      for (int i = 1; i <= n; ++i) {
        printf("%d ", b[i]);
      }
      cout << endl;
    }
  }
  return 0;
}
