#include <bits/stdc++.h>
using namespace std;
int t, n;
vector<int> UPD[500005];
int a[500005], ans[500005];
void init() {
  for (int i = 1; i <= n + 1; i++) UPD[i].clear();
}
void topo_sort() {
  int pos = n;
  queue<int> que;
  que.push(n + 1);
  while (!que.empty()) {
    int u = que.front();
    que.pop();
    for (int i = 0; i < UPD[u].size(); i++) {
      ans[UPD[u][i]] = pos--;
      que.push(UPD[u][i]);
    }
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    init();
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    set<int> s;
    bool flag = false;
    for (int i = 1; i <= n; i++) {
      if (a[i] == -1) a[i] = i + 1;
      if (s.find(i) != s.end()) s.erase(i);
      if (!s.empty() && *s.begin() < a[i]) {
        flag = true;
        break;
      }
      s.insert(a[i]);
      UPD[a[i]].push_back(i);
    }
    if (flag) {
      puts("-1");
      continue;
    }
    topo_sort();
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
