#include <bits/stdc++.h>
template <class C, class E>
inline bool contains(const C& container, const E& element) {
  return container.find(element) != container.end();
}
template <class T>
inline void checkmin(T& a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T& a, T b) {
  if (b > a) a = b;
}
using namespace std;
vector<int> nextG;
vector<int> res;
vector<vector<int>> nextInv;
int n;
bool Solve(int from, int fromNum, int count) {
  assert(count >= 0);
  if (count == 0) return true;
  int to = from + count - 1;
  int toNum = fromNum + count - 1;
  vector<int>& pointsToNext = nextInv[to + 1];
  auto itIndexPointsToEnd =
      lower_bound((pointsToNext).begin(), (pointsToNext).end(), from);
  if (itIndexPointsToEnd == pointsToNext.end() || *itIndexPointsToEnd > to) {
    if (nextG[to] == -1) {
      res[to] = toNum;
      return Solve(from, fromNum, count - 1);
    }
    return false;
  }
  int indexPointsToEnd = *itIndexPointsToEnd;
  res[indexPointsToEnd] = toNum;
  int lowerIntSize = indexPointsToEnd - from;
  return Solve(from, fromNum, lowerIntSize) &&
         Solve(indexPointsToEnd + 1, fromNum + lowerIntSize,
               count - 1 - lowerIntSize);
}
void Solve() {
  nextInv = vector<vector<int>>(n + 2);
  ;
  for (int i = (1), _b = (n); i <= _b; i++) {
    if (nextG[i] != -1) nextInv[nextG[i]].push_back(i);
  }
  if (Solve(1, 1, n)) {
    for (int i = (1), _b = (n); i <= _b; i++) cout << res[i] << " ";
  } else
    cout << -1;
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << std::setprecision(15);
  cout << std::fixed;
  int t;
  cin >> t;
  for (int i = (0), _b = ((t)-1); i <= _b; i++) {
    cin >> n;
    nextG.resize(n + 1);
    res.resize(n + 1);
    for (int j = (1), _b = (n); j <= _b; j++) {
      res[j] = 0;
      cin >> nextG[j];
    }
    Solve();
  }
  return 0;
}
