#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)5e5 + 100;
const int maxm = (int)1e6 + 100;
const int mod = (int)1e9 + 7;
const int P = (int)1e6 + 7;
const double pi = acos(-1.0);
int n, ans[maxn], timer, p[maxn], need[maxn];
vector<int> g[maxn];
void dfs(int v) {
  ans[v] = timer--;
  for (auto to : g[v]) dfs(to);
}
bool check() {
  stack<int> st;
  for (int i = (n); i >= (1); --i) {
    while (((int)(st).size()) && ans[st.top()] < ans[i]) st.pop();
    if (((int)(st).size()))
      need[i] = st.top();
    else
      need[i] = n + 1;
    st.push(i);
  }
  for (int i = (1); i <= (n); ++i)
    if (p[i] != -1 && p[i] != need[i]) return 0;
  return 1;
}
void solve() {
  scanf("%d", &n);
  for (int i = (1); i <= (n + 1); ++i) g[i].clear();
  timer = n + 1;
  for (int i = (1); i <= (n); ++i) {
    scanf("%d", &p[i]);
    if (p[i] == -1)
      g[i + 1].push_back(i);
    else
      g[p[i]].push_back(i);
  }
  dfs(n + 1);
  bool ok = check();
  if (!ok) {
    puts("-1");
    return;
  }
  for (int i = (1); i <= (n); ++i) printf("%d ", ans[i]);
  puts("");
}
int main() {
  int t = 1;
  scanf("%d", &t);
  while (t--) solve();
}
