#include <bits/stdc++.h>
using namespace std;
const int M = 5e5 + 239;
int qt, n, e[M], t, c[M], p, ct[M];
bool ch;
int main() {
  cin >> qt;
  for (int qe = 0; qe < qt; qe++) {
    cin >> n;
    ch = true;
    for (int i = 0; i < n; i++) {
      cin >> t;
      e[i] = (t == -1) ? (i + 1) : (t - 1);
      if (e[i] <= i) ch = false;
    }
    p = 0;
    c[0] = n;
    for (int i = 0; ch && i < n; i++) {
      if (i == c[p]) p--;
      if (e[i] < c[p])
        c[++p] = e[i];
      else if (e[i] > c[p])
        ch = false;
    }
    if (!ch)
      cout << "-1\n";
    else {
      for (int i = 0; i < n; i++) ct[i] = 0;
      for (int i = 0; i < n; i++) ct[e[i] - 1]++;
      for (int i = 1; i < n; i++) ct[i] += ct[i - 1];
      for (int i = 0; i < n; i++) cout << ct[e[i] - 1]-- << " ";
      cout << "\n";
    }
  }
  return 0;
}
