#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
vector<vector<int> > adj;
int ans[N];
bool vis[N];
int mx;
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  for (int i = 0; i < adj[x].size(); i++) dfs(adj[x][i]);
  ans[x] = ++mx;
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    mx = 0;
    scanf("%d", &n);
    vector<int> v[n + 2];
    for (int i = 1; i <= n; i++) vis[i] = 0;
    int Z[n + 2];
    adj = vector<vector<int> >(n + 2);
    int z = 0;
    bool no = 0;
    for (int i = 1; i <= n; i++) {
      int x;
      scanf("%d", &x);
      Z[i] = x;
      if (x == -1) x = i + 1;
      if (x > z && z > i) no = 1;
      z = max(x, z);
      v[x].push_back(i);
    }
    if (no) {
      printf("-1\n");
      continue;
    }
    for (int i = 1; i <= n; i++) {
      if (v[i].empty()) continue;
      sort(v[i].begin(), v[i].end());
      adj[i].push_back(v[i][0]);
      for (int j = 1; j < v[i].size(); j++) {
        adj[v[i][j - 1]].push_back(v[i][j]);
      }
    }
    for (int i = n; i >= 1; i--) {
      if (vis[i]) continue;
      dfs(i);
    }
    int temp[n + 2];
    for (int i = 1; i <= n; i++) temp[i] = n + 1;
    stack<int> stk;
    for (int i = 1; i <= n; i++) {
      while (stk.size() && ans[i] > ans[stk.top()]) {
        temp[stk.top()] = i;
        stk.pop();
      }
      stk.push(i);
    }
    for (int i = 1; i <= n; i++) {
      if (Z[i] == -1) continue;
      if (Z[i] != temp[i]) no = 1;
    }
    if (no) {
      printf("-1\n");
      continue;
    }
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
