#include <bits/stdc++.h>
using namespace std;
template <class T>
struct rge {
  T b, e;
};
template <class T>
rge<T> range(T i, T j) {
  return rge<T>{i, j};
}
struct debug {
  template <class T>
  debug& operator<<(const T&) {
    return *this;
  }
};
using ll = long long;
template <typename T>
void min_self(T& a, T b) {
  a = min(a, b);
}
template <typename T>
void max_self(T& a, T b) {
  a = max(a, b);
}
const int mxN = 500 * 1000 + 5;
int t;
vector<vector<int>> g;
int ans[mxN];
bool valid_input(vector<int> a) {
  int n = a.size();
  vector<int> tree(2 * n);
  for (int i = 0; i < int(n); i++) tree[i + n] = a[i];
  for (int i = n - 1; i > 0; i--) {
    tree[i] = max(tree[2 * i], tree[2 * i + 1]);
  }
  auto get_max = [&](int i, int j) {
    int res = -1;
    for (i += n, j += n; i <= j; i /= 2, j /= 2) {
      if (i % 2 == 1) max_self(res, tree[i++]);
      if (j % 2 == 0) max_self(res, tree[j--]);
    }
    return res;
  };
  for (int i = 0; i < int(n); i++) {
    if (get_max(i + 1, a[i] - 1) > a[i]) {
      return false;
    }
  }
  return true;
}
void dfs(int u) {
  ans[u] = t--;
  for (int v : g[u]) dfs(v);
}
void test_case() {
  g.clear();
  int n;
  cin >> n;
  t = n;
  g.resize(n + 1);
  vector<int> nxt(n);
  for (int i = 0; i < int(n); i++) {
    cin >> nxt[i];
    if (nxt[i] == -1) {
      nxt[i] = i + 1;
    } else {
      nxt[i]--;
    }
    g[nxt[i]].push_back(i);
  }
  if (!valid_input(nxt)) {
    cout << "-1\n";
    return;
  }
  t = n;
  dfs(n);
  for (int i = 0; i < int(n); i++) {
    cout << ++ans[i] << " \n"[i == n - 1];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    test_case();
  }
}
