#include <bits/stdc++.h>
using namespace std;
const int INF = 4e5;
void run_case() {
  int n, i, j, k;
  cin >> n;
  vector<int> a(n);
  vector<vector<int>> where(n + 1);
  for (i = 0; i < n; i++) {
    cin >> a[i];
    where[a[i]].push_back(i + 1);
  }
  for (i = 1; i <= n; i++) sort(where[i].begin(), where[i].end());
  vector<int> ans(n + 1, -1);
  vector<bool> vis(n + 1, false);
  for (i = 1; i <= n; i++) {
    int dis = -1e9, pr = 0;
    where[i].push_back(n + 1);
    for (int pos : where[i]) {
      dis = max(dis, pos - pr);
      pr = pos;
    }
    for (j = dis; j <= n; j++) {
      if (!vis[j]) {
        ans[j] = i;
        vis[j] = true;
      } else
        break;
    }
  }
  for (i = 1; i <= n; i++) cout << ans[i] << " ";
  cout << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    run_case();
  }
}
