#include <bits/stdc++.h>
using namespace std;
inline long long gi() {
  long long _x = 0, _tmp = 1;
  char _tc = getchar();
  while ((_tc < '0' || _tc > '9') && _tc != '-') _tc = getchar();
  if (_tc == '-') _tc = getchar(), _tmp = -1;
  while (_tc >= '0' && _tc <= '9') _x *= 10, _x += (_tc - '0'), _tc = getchar();
  return _x * _tmp;
}
void bye() {
  puts("-1");
  exit(0);
}
long long mod7 = 1e9 + 7;
long long inf = INT_MAX - 10;
long long ncase = 1;
long long N, M;
string str;
const int mxn = 5e5 + 5;
vector<int> A, ans;
vector<int> G[mxn];
void pre() { return; }
void init() {
  N = gi();
  A = vector<int>(N);
  ans = vector<int>(N + 1);
  for (int i = 0; i < N; ++i) A[i] = gi() - 1;
}
int tag;
void dfs(int n) {
  for (int i : G[n]) dfs(i);
  ans[n] = tag++;
}
void sol() {
  for (int i = 0; i < N; ++i)
    if (A[i] == -2) A[i] = i + 1;
  vector<int> stk;
  for (int i = 0; i < N; ++i) {
    if (stk.empty())
      stk.push_back(A[i]);
    else {
      if (stk.back() == i) stk.pop_back();
      if (stk.empty()) stk.push_back(A[i]);
      if (A[i] > stk.back()) return puts("-1"), void();
      if (A[i] < stk.back()) stk.push_back(A[i]);
    }
  }
  for (int i = 0; i <= N; ++i) G[i].clear();
  for (int i = 0; i < N; ++i) G[A[i]].push_back(i);
  for (int i = 0; i <= N; ++i) reverse((G[i]).begin(), (G[i]).end());
  tag = 1;
  dfs(N);
  for (int i = 0; i < N; ++i) cout << ans[i] << " \n"[i + 1 == N];
  return;
}
int main() {
  pre();
  ncase = gi();
  while (ncase--) {
    init();
    sol();
  }
  return 0;
}
