#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
vector<int> edges[maxn];
int a[maxn], b[maxn], vis[maxn];
int cur;
int main(int argc, char const *argv[]) {
  int test;
  scanf("%d", &test);
  while (test--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n + 1; ++i) {
      edges[i].clear();
      b[i] = vis[i] = 0;
    }
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &a[i]);
      if (a[i] != -1) {
        edges[a[i]].push_back(i);
      }
    }
    cur = n;
    for (int i = n + 1; i > 0; --i) {
      if (edges[i].empty() or b[i] != 0) continue;
      stack<int> st;
      st.push(i);
      while (!st.empty()) {
        int x = st.top();
        st.pop();
        if (x != n + 1) {
          b[x] = cur--;
        } else {
          b[x] = n + 1;
        }
        for (int i = edges[x].size() - 1; i >= 0; --i) {
          st.push(edges[x][i]);
        }
      }
    }
    for (int i = 1; i <= n; ++i) {
      if (a[i] == -1 && b[i] == 0) {
        b[i] = cur--;
      }
    }
    vector<int> nxt(n + 2);
    stack<int> st;
    for (int i = n; i > 0; --i) {
      while (!st.empty() && b[i] >= b[st.top()]) {
        st.pop();
      }
      if (st.empty()) {
        nxt[i] = n + 1;
      } else {
        nxt[i] = st.top();
      }
      st.push(i);
    }
    bool good = 1;
    for (int i = 1; i <= n; ++i) {
      if (a[i] != nxt[i] && a[i] != -1) {
        good = 0;
        break;
      }
    }
    if (!good) {
      printf("-1\n");
    } else {
      for (int i = 1; i <= n; ++i) {
        printf("%d ", b[i]);
      }
      printf("\n");
    }
  }
  return 0;
}
