#include <bits/stdc++.h>
using namespace std;
int arr[500001];
int ans[500001];
bool vis[500001];
int id;
int n;
void dfs(int u) {
  vis[u] = 1;
  if (arr[u] == n) {
    ans[u] = id--;
  } else if (arr[u] == -2) {
    ans[u] = id--;
    arr[u] = n;
  } else {
    if (!vis[arr[u]]) dfs(arr[u]);
    ans[u] = id--;
  }
}
int main() {
  int t;
  for (cin >> t; t--;) {
    scanf("%d", &n);
    for (int i = 0; i != n; ++i) {
      scanf("%d", &arr[i]);
      --arr[i];
    }
    bool f = 1;
    priority_queue<int> pq;
    for (int i = 0; i != n; ++i) {
      vis[i] = 0;
      if (arr[i] == -2) continue;
      if (!pq.empty()) {
        while (!pq.empty() && -pq.top() <= i) pq.pop();
        if (!pq.empty()) {
          if (arr[i] > -pq.top()) {
            f = 0;
            break;
          }
        }
        pq.push(-arr[i]);
      } else
        pq.push(-arr[i]);
    }
    if (!f) {
      printf("-1\n");
      continue;
    }
    id = n;
    for (int u = 0; u != n; ++u)
      if (arr[u] != -2 && !vis[u]) dfs(u);
    for (int u = 0; u != n; ++u)
      if (arr[u] == -2) {
        ans[u] = id--;
      }
    for (int i = 0; i != n; ++i) printf("%d ", ans[i]);
    printf("\n");
  }
}
