#include <bits/stdc++.h>
using namespace std;
const int maxN = 500042;
int nxt[maxN], res[maxN];
bool fail;
void go(int a, int b, int v) {
  if (fail) return;
  for (; a <= b; a = nxt[a] == -1 ? a + 1 : nxt[a]) {
    if (nxt[a] > b + 1 or fail) {
      fail = true;
      return;
    }
    if (nxt[a] != -1 and nxt[a] != a + 1)
      go(a + 1, nxt[a] - 1, v), v += nxt[a] - a - 1;
    res[a] = v++;
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int i = (1); i < (n + 1); i++) scanf("%d", nxt + i);
    go(1, n, 1);
    if (fail)
      printf("-1");
    else
      for (int i = (1); i < (n + 1); i++) printf("%d ", res[i]);
    printf("\n");
    fail = false;
  }
  return 0;
}
