#include <bits/stdc++.h>
using namespace std;
const int MAXN = 512345;
int n;
int v[MAXN];
int ans[MAXN];
void solve() {
  stack<int> s;
  int curr = 1;
  for (int i = 0; i < n; ++i) {
    while (!s.empty() && v[s.top()] == i) {
      ans[s.top()] = curr++;
      s.pop();
    }
    if (s.empty()) {
      s.push(i);
    } else {
      if (v[i] > v[s.top()]) {
        printf("-1\n");
        return;
      } else {
        s.push(i);
      }
    }
  }
  while (!s.empty()) {
    ans[s.top()] = curr++;
    s.pop();
  }
  for (int i = 0; i < n; ++i) printf("%d ", ans[i]);
  printf("\n");
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
      scanf("%d", v + i);
      if (v[i] == -1) v[i] = i + 2;
      --v[i];
    }
    solve();
  }
  return 0;
}
