#include <bits/stdc++.h>
using namespace std;
int nxt[500005], cur[500005], mas[500005], uk;
vector<int> g[500050];
void dfs(int v) {
  mas[v] = uk--;
  for (auto d : g[v]) dfs(d);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  int q;
  cin >> q;
  for (int i = 1; i <= q; ++i) {
    int n;
    cin >> n;
    for (int j = 1; j <= n + 1; ++j) g[j].clear();
    for (int j = 1; j <= n; ++j) {
      cin >> nxt[j];
      if (nxt[j] != -1)
        g[nxt[j]].push_back(j);
      else
        g[j + 1].push_back(j);
    }
    for (int j = 1; j <= n; ++j)
      if (g[j].size() != 0) sort(g[j].begin(), g[j].end());
    uk = n + 1;
    dfs(n + 1);
    stack<int> st;
    for (int j = n; j >= 1; --j) {
      while (!st.empty() && mas[st.top()] < mas[j]) st.pop();
      if (st.empty())
        cur[j] = n + 1;
      else
        cur[j] = st.top();
      st.push(j);
    }
    for (int j = 1; j <= n; ++j) {
      if (nxt[j] == -1) continue;
      if (nxt[j] != cur[j]) {
        goto Label;
      }
    }
    for (int j = 1; j <= n; ++j) cout << mas[j] << ' ';
    cout << '\n';
    continue;
  Label:
    cout << -1 << '\n';
  }
  return 0;
}
