#include <bits/stdc++.h>
int main() {
  int nt;
  scanf("%d", &nt);
  for (int t = 0; t < nt; ++t) {
    int n;
    scanf("%d", &n);
    const int WH = 0, GR = 1, BL = 2;
    std::vector<int> next(n), v, col(n, WH);
    for (int i = 0; i < n; ++i) {
      scanf("%d", &next[i]);
      if (next[i] > 0) --next[i];
    }
    bool cf = false;
    std::function<void(int)> dfs = [&](int cur) {
      if (cf) return;
      if (col[cur] == GR) {
        cf = true;
        return;
      }
      col[cur] = GR;
      if (next[cur] != -1 && next[cur] != n && col[next[cur]] != BL)
        dfs(next[cur]);
      v.push_back(cur);
      col[cur] = BL;
    };
    for (int i = 0; i < n && !cf; ++i) {
      if (col[i] == WH) {
        dfs(i);
      }
    }
    if (cf) {
      printf("-1");
    } else {
      std::vector<int> ans(n), t(n);
      std::reverse(v.begin(), v.end());
      for (int i = 0; i < (int)v.size(); ++i) {
        ans[v[i]] = i + 1;
      }
      t[n - 1] = n;
      for (int i = n - 2; i >= 0; --i) {
        int cur = i + 1;
        while (cur < n && ans[cur] < ans[i]) {
          cur = t[cur];
        }
        t[i] = cur;
      }
      bool match = true;
      for (int i = 0; i < n; ++i) {
        if (next[i] != -1 && next[i] != t[i]) {
          match = false;
          break;
        }
      }
      if (!match) {
        printf("-1");
      } else {
        for (int x : ans) {
          printf("%d ", x);
        }
      }
    }
    printf("\n");
  }
}
