#include <bits/stdc++.h>
using namespace std;
struct SegmentTree {
  pair<int, int> tree[4 * 500005 + 5];
  int lazy[4 * 500005 + 5];
  void init(int k, int p, int q) {
    lazy[k] = 0;
    if (p == q) {
      tree[k] = pair<int, int>(0, p);
      return;
    }
    init(k * 2, p, (p + q) / 2);
    init(k * 2 + 1, (p + q) / 2 + 1, q);
    tree[k] = min(tree[k * 2], tree[k * 2 + 1]);
  }
  void update(int k, int p, int q, int u, int v, int z) {
    if (p > v || u > q) return;
    if (p >= u && v >= q) {
      tree[k].first += z;
      lazy[k] += z;
      return;
    }
    update(k * 2, p, (p + q) / 2, u, v, z);
    update(k * 2 + 1, (p + q) / 2 + 1, q, u, v, z);
    if (tree[k * 2].first <= tree[k * 2 + 1].first)
      tree[k] = pair<int, int>(tree[k * 2].first + lazy[k], tree[k * 2].second);
    else
      tree[k] = pair<int, int>(tree[k * 2 + 1].first + lazy[k],
                               tree[k * 2 + 1].second);
  }
  pair<int, int> get() { return tree[1]; }
};
SegmentTree segment_tree;
vector<pair<int, int> > adj[500005];
int n;
int ans[500005];
const int inf = 1e9;
void solve() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    while (!adj[i].empty()) adj[i].pop_back();
  segment_tree.init(1, 1, n);
  for (int i = 1; i <= n; i++) {
    int nxt;
    scanf("%d", &nxt);
    if (nxt == -1) continue;
    if (i + 1 <= nxt - 1) {
      adj[i].push_back(pair<int, int>(i + 1, nxt - 1));
      segment_tree.update(1, 1, n, i + 1, nxt - 1, 1);
    }
    if (nxt != n + 1) {
      adj[nxt].push_back(pair<int, int>(i, i));
      segment_tree.update(1, 1, n, i, i, 1);
    }
  }
  for (int i = n; i >= 1; i--) {
    pair<int, int> min_val = segment_tree.get();
    if (min_val.first != 0) {
      printf("-1\n");
      return;
    }
    ans[min_val.second] = i;
    for (int x = 0; x < adj[min_val.second].size(); x++) {
      pair<int, int> seg = adj[min_val.second][x];
      segment_tree.update(1, 1, n, seg.first, seg.second, -1);
    }
    segment_tree.update(1, 1, n, min_val.second, min_val.second, inf);
  }
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  printf("\n");
}
int main() {
  int t;
  scanf("%d", &t);
  for (int i = 1; i <= t; i++) solve();
}
