#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 5;
int n, a[N], in[N], sum[N], R[N];
vector<int> G[N], V;
int ans[N];
vector<pair<int, int> > s;
bool cmp(pair<int, int> a, pair<int, int> b) {
  if (a.first != b.first) return a.first > b.first;
  return a.second < b.second;
}
void solve() {
  s.clear();
  int cur = n;
  for (int i = (1); i < (n + 1); i++)
    if (a[i] == -1) a[i] = i + 1;
  for (int i = (1); i < (n + 1); i++) s.push_back(pair<int, int>(a[i], i));
  sort(s.begin(), s.end(), cmp);
  for (auto it : s) {
    ans[it.second] = cur;
    cur--;
  }
  for (int i = (1); i < (n + 1); i++) cout << ans[i] << " ";
  cout << endl;
}
stack<int> stk;
int main() {
  int TTT;
  cin >> TTT;
  while (TTT--) {
    cin >> n;
    int mx = 0;
    V.clear();
    while (!stk.empty()) stk.pop();
    for (int i = (1); i < (n + 1); i++) {
      cin >> a[i], in[i] = 0, sum[i] = 0;
      G[i].clear();
      if (a[i] > 0) V.push_back(i), V.push_back(a[i]), R[i] = a[i];
    }
    sort(V.begin(), V.end());
    int r = 0;
    for (auto v : V) {
      if (!stk.empty() && R[stk.top()] == v)
        stk.pop();
      else
        stk.push(v);
    }
    if ((int)stk.size())
      cout << "-1"
           << "\n";
    else
      solve();
  }
  return 0;
}
