#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> n;
    vector<int> a(n, -1);
    vector<int> full(n, -1);
    int cur = 1;
    stack<pair<int, int>> st;
    bool f = true;
    int cur2 = 0;
    for (int j = 0; j < n; j++) {
      int fi = -1;
      while (!st.empty() && st.top().second == j) {
        fi = st.top().first;
        st.pop();
      }
      if (fi > -1) {
        int k = j - 1;
        while (k >= fi) {
          if (full[k] != -1)
            k = full[k] - 1;
          else {
            a[k] = cur++;
            k--;
          }
        }
        full[j - 1] = fi;
      }
      int next;
      cin >> next;
      if (next != -1) {
        next--;
        if (!st.empty() && st.top().second < next)
          f = false;
        else
          st.push(make_pair(j, next));
      }
    }
    if (!f)
      cout << "-1\n";
    else {
      int fi = 0;
      while (!st.empty()) {
        fi = st.top().first;
        st.pop();
      }
      {
        int k = n - 1;
        while (k >= 0) {
          if (full[k] != -1)
            k = full[k] - 1;
          else {
            a[k] = cur++;
            k--;
          }
        }
      }
      for (int j = 0; j < n; j++) cout << a[j] << " ";
      cout << "\n";
    }
  }
  return 0;
}
