#include <bits/stdc++.h>
using namespace std;
int d[1000000 + 10], net[1000000 + 10], res[1000000 + 10];
int cnt;
bool check(int l, int r) {
  while (l != r) {
    if (net[l] > r) return false;
    if (!check(l + 1, net[l])) return false;
    res[l] = cnt++;
    l = net[l];
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    cnt = 1;
    for (int i = (1); i < (n + 1); i++) d[i] = 0;
    for (int i = (1); i < (n + 1); i++) {
      cin >> net[i];
      if (net[i] == -1) net[i] = i + 1;
      d[net[i]]++;
    }
    if (check(1, n + 1)) {
      for (int i = (1); i < (n + 1); i++) {
        cout << res[i] << " ";
      }
      cout << "\n";
    } else {
      cout << "-1"
           << "\n";
    }
  }
  return 0;
}
