#include <bits/stdc++.h>
using namespace std;
template <class T>
int chkmax(T& a, T b) {
  if (b > a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
int chkmin(T& a, T b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class iterator>
void output(iterator begin, iterator end, ostream& out = cerr) {
  while (begin != end) {
    out << (*begin) << " ";
    begin++;
  }
  out << endl;
}
template <class T>
void output(T x, ostream& out = cerr) {
  output(x.begin(), x.end(), out);
}
void fast_io() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int _n, n;
vector<vector<int> > g;
void build(int v, int tl, int tr) {
  if (tl == tr) {
    return;
  }
  g[v].push_back(2 * v);
  g[v].push_back(2 * v + 1);
  int tm = (tl + tr) >> 1;
  build(v * 2, tl, tm);
  build(v * 2 + 1, tm + 1, tr);
}
void make_edge(int u, int l, int r, int v, int tl, int tr) {
  if (l > r) {
    return;
  }
  if (l == tl && r == tr) {
    g[u].push_back(v);
  } else {
    int tm = (tl + tr) >> 1;
    make_edge(u, l, min(r, tm), v * 2, tl, tm);
    make_edge(u, max(l, tm + 1), r, v * 2 + 1, tm + 1, tr);
  }
}
vector<int> out, _out, used;
void dfs(int v) {
  used[v] = 1;
  for (auto v1 : g[v]) {
    if (used[v1] == 0) {
      dfs(v1);
    }
  }
  _out[v] = out.size();
  out.push_back(v);
}
void solve_one() {
  cin >> _n;
  n = 1;
  while (n < _n) {
    n <<= 1;
  }
  int V = 2 * n;
  g.resize(V);
  for (int i = 0; i < V; ++i) {
    g[i].clear();
  }
  build(1, 0, n - 1);
  vector<int> nxt(_n);
  for (int i = 0; i < _n; ++i) {
    cin >> nxt[i];
    if (nxt[i] == -1) {
      continue;
    }
    nxt[i]--;
    make_edge(i + n, i + 1, nxt[i] - 1, 1, 0, n - 1);
    if (nxt[i] < _n) {
      g[nxt[i] + n].push_back(i + n);
    }
  }
  out.clear();
  _out.assign(V, 0);
  used.assign(V, 0);
  for (int i = 0; i < V; ++i) {
    if (used[i] == 0) {
      dfs(i);
    }
  }
  for (int i = 0; i < V; ++i) {
    for (auto v : g[i]) {
      if (_out[v] > _out[i]) {
        cout << -1 << endl;
        return;
      }
    }
  }
  vector<int> ans(n);
  int ptr = 0;
  for (auto x : out) {
    if (x >= n) {
      ans[x - n] = ptr++;
    }
  }
  for (int i = 0; i < _n; ++i) {
    cout << ans[i] + 1 << " ";
  }
  cout << endl;
}
signed main() {
  fast_io();
  int T;
  cin >> T;
  for (int i = 0; i < T; ++i) {
    solve_one();
  }
}
