#include <bits/stdc++.h>
using namespace std;
void file(bool opt) {
  if (opt && fopen("in.txt", "r")) {
    freopen("in.txt", "r", stdin);
  }
}
int n;
vector<int> edge[500000 + 5];
int a[500000 + 5];
int ans[500000 + 5];
stack<pair<int, int>> stk;
int tot;
void topsort() {
  queue<int> que;
  que.push(n + 1);
  while (que.size()) {
    int u = que.front();
    que.pop();
    int up = edge[u].size();
    for (int i = 0; i < up; i++) {
      int v = edge[u][i];
      ans[v] = tot--;
      que.push(v);
    }
  }
}
int main() {
  file(1);
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    bool flag = 1;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (a[i] == -1) a[i] = i + 1;
      while (!stk.empty() && stk.top().second <= i) stk.pop();
      if (!stk.empty() && stk.top().second < a[i])
        flag = 0;
      else {
        stk.push({i, a[i]});
        edge[a[i]].push_back(i);
      }
    }
    tot = n;
    if (!flag)
      puts("-1");
    else {
      topsort();
      for (int i = 1; i <= n; i++) printf("%d%c", ans[i], i == n ? '\n' : ' ');
    }
    while (!stk.empty()) stk.pop();
    for (int i = 0; i <= n + 1; i++) edge[i].clear();
  }
  return 0;
}
