#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void boostIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
}
bool isPrime(int x) {
  if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
  for (int i = 5; i * i <= x; i += 6)
    if (x % i == 0 || x % (i + 2) == 0) return 0;
  return 1;
}
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
  return a * b / gcd(a, b);
}
long long Mod = 1e9 + 7;
long long inf = 1e18 + 3e17;
vector<long long> A;
vector<long long> Ans;
bool flag = 1;
void f(long long i, long long last, long long k = 1) {
  if (i == A.size()) return;
  if (i >= last) return;
  if (A[i] == -1) {
    Ans[i] = k;
    f(i + 1, last, k + 1);
    return;
  }
  if (A[i] > last || A[i] < i) {
    flag = 0;
    return;
  }
  long long sz = A[i] - i - 1;
  Ans[i] = k + sz;
  f(i + 1, A[i], k);
  f(A[i], last, k + sz + 1);
  return;
}
int32_t main() {
  boostIO();
  long long T;
  cin >> T;
  while (T--) {
    long long n;
    cin >> n;
    A.assign(n + 1, 0);
    Ans.assign(n + 1, 0);
    flag = 1;
    for (long long i = 0; i < (n); ++i) {
      cin >> A[i + 1];
    }
    f(1, n + 1);
    cerr << "ANS: ";
    if (flag == 0) {
      cout << "-1" << '\n';
      continue;
    }
    for (long long i = 1; i <= n; ++i) {
      cout << Ans[i] << " ";
    }
    cout << '\n';
  }
}
