#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const int MX = 5e5 + 9;
int t, cnt;
int n, a[MX], p[MX], ok = 1, c[MX];
int check(int l, int r) {
  if (!ok) return 0;
  if (l == r) return a[l];
  if (l + 1 == r) {
    if (a[l] == r) return a[l];
    if (a[l] == -1) return 0;
    ok = 0;
    return 0;
  }
  int ans = 0;
  for (int i = l + 1; i < r;) {
    if (a[i] == -1) {
      i++;
      continue;
    }
    if (a[i] > r) {
      ok = 0;
      return 0;
    }
    if (!ok) return 0;
    ans = max(ans, check(i, a[i]));
    if (!ok) return 0;
    if (ans > r) {
      ok = 0;
      return 0;
    }
    i = a[i];
  }
  return ans;
}
vector<int> v[MX];
int vis[MX];
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  if (x <= n) p[x] = cnt--;
  if (a[x] == -1) return;
  for (auto pp : v[x]) {
    dfs(pp);
  }
}
int main() {
  cin >> t;
  while (t--) {
    ok = 1;
    scanf("%d", &n);
    for (int i = 1; i <= n + 1; i++) p[i] = -1, vis[i] = 0, v[i].clear();
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) {
      if (a[i] == -1)
        v[i + 1].push_back(i);
      else
        v[a[i]].push_back(i);
    }
    for (int i = 1; i <= n + 1; i++) sort(v[i].begin(), v[i].end());
    for (int i = 1; i <= n;) {
      if (a[i] == -1) {
        i++;
      } else {
        if (check(i, a[i]) > a[i]) {
          ok = 0;
          break;
        }
        i = a[i];
        if (!ok) break;
      }
    }
    if (!ok) {
      puts("-1");
      continue;
    }
    cnt = n;
    for (int i = n + 1; i >= 1; i--) {
      for (auto pp : v[i]) {
        p[pp] = cnt--;
      }
    }
    for (int i = 1; i <= n; i++) cout << p[i] << " ";
    puts("");
  }
}
