#include <bits/stdc++.h>
using namespace std;
int n, m, k, ans[1010101], par[1010101], mod = 1e9 + 7;
int sum = 1, lv = -1;
int dfs(int v, vector<vector<int>> &graph) {
  if (lv != v) return -1;
  lv--;
  int i;
  for (i = 0; i < graph[v].size(); i++) {
    int j = graph[v][i];
    if (dfs(j, graph) == -1) return -1;
  }
  ans[v] = sum++;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int i, j, temp = 0;
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    sum = 1;
    lv = n + 1;
    vector<vector<int>> graph(n + 2);
    for (i = 1; i <= n; i++) {
      cin >> par[i];
      if (par[i] == -1) par[i] = i + 1;
      graph[par[i]].push_back(i);
    }
    for (i = 1; i <= n + 1; i++)
      sort(graph[i].begin(), graph[i].end(), greater<int>());
    if (dfs(n + 1, graph) == -1) {
      cout << "-1\n";
      continue;
    }
    for (i = 1; i <= n; i++) cout << ans[i] << ' ';
    cout << '\n';
  }
}
