#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 5e5 + 5;
int n;
int nxt[N];
int in[4 * N], node[N], cntNodes = 0;
vector<int> adj[4 * N];
int isLeaf[4 * N], idx[4 * N];
int ans[N];
void build(int cur, int s, int e) {
  in[cur] = 0;
  adj[cur].clear();
  cntNodes++;
  isLeaf[cur] = 0;
  if (s == e) {
    node[s] = cur;
    idx[cur] = s;
    isLeaf[cur] = 1;
    return;
  }
  int l = 2 * cur + 1;
  int r = 2 * cur + 2;
  int mid = (s + e) / 2;
  build(l, s, mid);
  build(r, mid + 1, e);
  in[l]++;
  in[r]++;
  adj[cur].push_back(l);
  adj[cur].push_back(r);
}
void addEdge(int cur, int s, int e, int i, int j, int u) {
  if (s > j || e < i) return;
  int l = 2 * cur + 1;
  int r = 2 * cur + 2;
  int mid = (s + e) / 2;
  if (s >= i && e <= j) {
    adj[u].push_back(cur);
    in[cur]++;
    return;
  }
  addEdge(l, s, mid, i, j, u);
  addEdge(r, mid + 1, e, i, j, u);
}
void solve() {
  scanf("%d", &n);
  cntNodes = 0;
  build(0, 0, n - 1);
  for (int i = 0; i < n; i++) {
    scanf("%d", nxt + i);
    if (nxt[i] != -1) --nxt[i];
    if (nxt[i] != -1) {
      if (nxt[i] < n) {
        in[node[i]]++;
        adj[node[nxt[i]]].push_back(node[i]);
      }
      if (nxt[i] > i + 1) addEdge(0, 0, n - 1, i + 1, nxt[i] - 1, node[i]);
    }
  }
  queue<int> q;
  q.push(0);
  int cnt = n;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    if (isLeaf[u]) ans[idx[u]] = cnt--;
    for (int i = 0; i < ((int)(adj[u]).size()); i++) {
      int v = adj[u][i];
      if (!--in[v]) q.push(v);
    }
  }
  if (cnt == 0)
    for (int i = 0; i < n; i++) printf("%d ", ans[i]);
  else
    printf("-1");
  printf("\n");
}
vector<int> g[N];
void solve2() {
  scanf("%d", &n);
  int cnt = n;
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  queue<int> q;
  for (int i = 0; i < n; i++) {
    scanf("%d", nxt + i);
    if (nxt[i] != -1)
      nxt[i]--;
    else
      nxt[i] = i + 1;
    if (nxt[i] == n)
      q.push(i);
    else
      g[nxt[i]].push_back(i);
  }
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    ans[u] = cnt--;
    for (int i = 0; i < ((int)(g[u]).size()); i++) {
      int v = g[u][i];
      q.push(v);
    }
  }
  stack<int> st;
  st.push(n);
  bool good = true;
  for (int i = n - 1; i >= 0; i--) {
    while (st.top() < nxt[i]) st.pop();
    if (st.top() != nxt[i]) {
      good = false;
      break;
    }
    st.push(i);
  }
  if (good) {
    for (int i = 0; i < n; i++) printf("%d ", ans[i]);
    printf("\n");
  } else {
    printf("-1\n");
  }
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) solve2();
  return 0;
}
