#include <bits/stdc++.h>
using namespace std;
int shifter = 2500000;
int P[3000006];
int visit[3000006], indegree[3000006], done[3000006];
vector<int> X[3000006], Y;
void build(int left, int right, int root) {
  if (left == right) {
    X[shifter + left].push_back(root);
    return;
  }
  int mid = (left + right) / 2;
  build(left, mid, root * 2);
  build(mid + 1, right, root * 2 + 1);
  X[root * 2].push_back(root);
  X[root * 2 + 1].push_back(root);
}
void update(int left, int right, int L, int R, int root, int toNode) {
  if (left > R || right < L) return;
  if (left >= L && right <= R) {
    X[root].push_back(toNode);
    return;
  }
  int mid = (left + right) / 2;
  update(left, mid, L, R, root * 2, toNode);
  update(mid + 1, right, L, R, root * 2 + 1, toNode);
}
int detectCycle(int x) {
  if (visit[x]) {
    if (visit[x] == 1) return 1;
    return 0;
  }
  visit[x] = 1;
  int ans = 0;
  for (auto z : X[x]) ans |= detectCycle(z);
  visit[x] = -1;
  return ans;
}
void dfs(int x) {
  if (done[x]) return;
  done[x] = 1;
  for (auto z : X[x]) dfs(z);
  if (x > shifter) Y.push_back(x - shifter);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL), cout.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    int N;
    cin >> N;
    for (int i = 1; i <= N + 1; i++)
      X[shifter + i].clear(),
          visit[shifter + i] = indegree[shifter + i] = done[shifter + i] = 0;
    for (int i = 1; i <= 4 * (N + 1); i++)
      X[i].clear(), visit[i] = indegree[i] = done[i] = 0;
    build(1, N + 1, 1);
    for (int i = 1; i <= N; i++) {
      int x;
      cin >> x;
      if (i == N) {
        x = N + 1;
        X[shifter + i].push_back(shifter + x), indegree[shifter + x]++;
        continue;
      }
      if (x == -1) {
        x = N + 1;
        X[shifter + i].push_back(shifter + x), indegree[shifter + x]++;
        continue;
      }
      indegree[shifter + i] += (x - 1 - i);
      update(1, N + 1, i + 1, x - 1, 1, shifter + i);
      X[shifter + i].push_back(shifter + x), indegree[shifter + x]++;
    }
    int isCycle = 0;
    for (int i = 1; i <= N; i++)
      if (!visit[shifter + i]) isCycle |= detectCycle(shifter + i);
    if (isCycle) {
      cout << -1 << "\n";
      continue;
    }
    Y.clear();
    for (int i = 1; i <= N; i++)
      if (indegree[shifter + i] == 0) dfs(shifter + i);
    reverse(Y.begin(), Y.end());
    for (int i = 1; i <= N; i++) P[Y[i - 1]] = i;
    for (int i = 1; i <= N; i++) cout << P[i] << " ";
    cout << "\n";
  }
  return 0;
}
