#include <bits/stdc++.h>
using namespace std;
long long int start_up() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  return 0;
}
long long int static r = start_up();
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> v(n);
  vector<vector<long long int>> v1(n);
  for (long long int i = 0; i < n; i++) {
    cin >> v.at(i);
    v.at(i)--;
    v1.at(v.at(i)).push_back(i);
  }
  vector<long long int> ans(n, -1);
  long long int nxt = n - 1;
  for (long long int i = 0; i < n; i++) {
    v1.at(i).push_back(n);
    long long int mx = -1, prev = -1;
    for (auto k : v1.at(i)) {
      mx = max(mx, k - prev);
      prev = k;
    }
    while (mx - 1 <= nxt && nxt >= 0) {
      ans.at(nxt) = i + 1;
      nxt--;
    }
  }
  for (long long int i = 0; i < n; i++) {
    cout << ans.at(i) << " ";
  }
  cout << endl;
}
signed main() {
  long long int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
