#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 500000;
vector<pair<int, int> > A;
vector<int> B;
int C[MAX_N + 1];
int main() {
  int t;
  for (scanf("%d", &t); t > 0; t--) {
    int n;
    scanf("%d", &n);
    A.clear();
    B.clear();
    bool flag = 1;
    for (int i = 1; i <= n; i++) {
      while (!A.empty() && A.back().second == i) {
        B.push_back(A.back().first);
        A.pop_back();
      }
      int a;
      scanf("%d", &a);
      if (a == -1)
        B.push_back(i);
      else {
        if (!A.empty() && a > A.back().second) flag = 0;
        A.emplace_back(i, a);
      }
    }
    while (!A.empty()) {
      B.push_back(A.back().first);
      A.pop_back();
    }
    if (!flag)
      printf("-1\n");
    else {
      for (int i = 1; i <= n; i++) C[B[i - 1]] = i;
      for (int i = 1; i <= n; i++) printf("%d%c", C[i], " \n"[i == n]);
    }
  }
}
