#include <bits/stdc++.h>
using namespace std;
constexpr int MAX_N = 524288;
int T;
int n;
array<int, 2 * MAX_N> segment;
array<int, MAX_N> nextPos;
array<int, MAX_N> answer;
vector<int> stck;
void update(int pos, int val) {
  int i = MAX_N + pos;
  segment[i] = val;
  i /= 2;
  while (i > 0) segment[i] = segment[2 * i] + segment[2 * i + 1], i /= 2;
}
void reset() {
  for (int i = 0; i < n; ++i) update(i, 0);
  for (int i = 0; i < n; ++i) nextPos[i] = 0;
  for (int i = 0; i < n; ++i) answer[i] = 0;
  stck.clear();
}
int getSum(int meFrom, int meTo, int from, int to, int pos) {
  if (from >= to) return 0;
  if (meTo <= from) return 0;
  if (to <= meFrom) return 0;
  if (from <= meFrom && meTo <= to) return segment[pos];
  int mid = (meFrom + meTo) / 2;
  return getSum(meFrom, mid, from, to, 2 * pos) +
         getSum(mid, meTo, from, to, 2 * pos + 1);
}
int main() {
  std::ios::sync_with_stdio(false);
  cin >> T;
  for (int testCase = 1; testCase <= T; ++testCase) {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> nextPos[i];
    for (int i = 0; i < n; ++i)
      if (nextPos[i] == -1)
        nextPos[i] = i + 1;
      else
        nextPos[i] -= 1;
    bool ok = true;
    int val = n;
    for (int i = 0; i < n && ok; ++i)
      if (answer[i] == 0) {
        int nextIdx = nextPos[i];
        stck.push_back(i);
        update(i, 1);
        if (getSum(0, MAX_N, stck.back() + 1, nextIdx, 1) != 0) ok = false;
        while (nextIdx != n && answer[nextIdx] == 0 && ok) {
          stck.push_back(nextIdx);
          update(nextIdx, 1);
          nextIdx = nextPos[nextIdx];
          if (getSum(0, MAX_N, stck.back() + 1, nextIdx, 1) != 0) ok = false;
        }
        while (!stck.empty() && ok)
          answer[stck.back()] = val, val -= 1, stck.pop_back();
      }
    if (ok) {
      for (int i = 0; i < n; ++i) cout << answer[i] << ' ';
      cout << '\n';
    } else
      cout << -1 << endl;
    reset();
  }
  return 0;
}
