#include <bits/stdc++.h>
using namespace std;
const int SI = 5e5 + 100;
int Next[SI];
int n;
vector<int> G[SI];
int du[SI];
int ad[SI];
int ans[SI];
int toR[SI];
void get_ad() {
  for (int i = 0; i <= n + 1; i++) toR[i] = i + 1;
  for (int i = n; i >= 1; i--) {
    if (Next[i] != -1) {
      int temp = 0;
      int j;
      for (j = i + 1; j <= n && j < Next[i];)
        if (ad[j] == -1) {
          ad[j] = i;
          j++;
        } else
          j = toR[j];
      toR[i] = Next[i];
    }
  }
}
int main() {
  int TTT;
  scanf("%d", &TTT);
  while (TTT--) {
    scanf("%d", &n);
    for (int i = 0; i <= n + 1; i++) {
      ad[i] = -1;
      du[i] = 0;
    }
    int mxR = 0;
    for (int i = 1; i <= n; i++) scanf("%d", &Next[i]);
    get_ad();
    for (int i = 1; i <= n; i++) {
      if (Next[i] != -1) {
        G[i].push_back(Next[i]);
        du[Next[i]]++;
      }
      if (ad[i] != -1) {
        G[i].push_back(ad[i]);
        du[ad[i]]++;
      }
    }
    queue<int> q;
    for (int i = 1; i <= n + 1; i++)
      if (du[i] == 0) q.push(i);
    int cnt = 0;
    int val = 0;
    while (q.empty() == false) {
      int now = q.front();
      if (now != n + 1) ans[now] = ++val;
      q.pop();
      cnt++;
      for (auto to : G[now]) {
        du[to]--;
        if (du[to] == 0) q.push(to);
      }
    }
    if (cnt == n + 1) {
      for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
      printf("\n");
    } else
      printf("-1\n");
    for (int i = 0; i <= n + 1; i++) G[i].clear();
  }
  return 0;
}
