#include <bits/stdc++.h>
using namespace std;
int T, n, nxt[500005], fwd[500005], lst[500005];
int ans[500005];
bool getans(int l, int r, int val) {
  if (l > r) return true;
  if (nxt[r] != r + 1) return false;
  if (l == r) {
    ans[l] = val;
    return true;
  }
  vector<int> v;
  v.clear();
  int x = r;
  while (x >= l) {
    v.push_back(x);
    x = lst[x];
  }
  for (int i = (int)v.size() - 1; i >= 0; i--) ans[v[i]] = val--;
  v.push_back(l - 1);
  for (int i = (int)v.size() - 2; i >= 0; i--) {
    if (!getans(v[i + 1] + 1, v[i] - 1, val)) return false;
    val -= v[i] - v[i + 1] - 1;
  }
  return true;
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 0; i <= n + 1; i++) fwd[i] = 0, lst[i] = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", nxt + i);
      if (nxt[i] == -1) nxt[i] = i + 1;
    }
    for (int i = 1; i <= n; i++) {
      lst[i] = fwd[nxt[i]];
      fwd[nxt[i]] = i;
    }
    if (!getans(1, n, n))
      puts("-1");
    else
      for (int i = 1; i <= n; i++) printf("%d%c", ans[i], " \n"[i == n]);
  }
  return 0;
}
