#include <bits/stdc++.h>
using namespace std;
const int maxn = 500003;
int n, a[maxn], ans[maxn], indeg[maxn];
vector<int> g[maxn];
set<int> st;
void topsort() {
  int cnt = n + 2;
  queue<int> q;
  q.push(n + 1);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    ans[u] = --cnt;
    for (int v : g[u]) {
      indeg[v]--;
      if (!indeg[v]) {
        q.push(v);
      }
    }
  }
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    bool flag = 1;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", a + i);
      if (flag == 0) continue;
      if (a[i] == -1) a[i] = i + 1;
      if (st.count(i)) st.erase(i);
      if (!st.empty() && *st.begin() < a[i]) flag = 0;
      st.insert(a[i]);
      g[a[i]].push_back(i);
      indeg[i]++;
    }
    if (!flag)
      puts("-1");
    else {
      topsort();
      for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
      puts("");
    }
    st.clear();
    for (int i = 1; i <= n + 1; i++) g[i].clear(), indeg[i] = 0;
  }
  return 0;
}
