#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2> a) {
  out << a.first << " " << a.second;
  return out;
}
template <typename T, typename T1>
T amax(T& a, T1 b) {
  if (b > a) a = b;
  return a;
}
template <typename T, typename T1>
T amin(T& a, T1 b) {
  if (b < a) a = b;
  return a;
}
const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;
const long long N = 3e5 + 5;
vector<long long> v[N];
long long ans[N];
void solve() {
  long long n;
  cin >> n;
  for (long long i = 1; i < n + 1; i++) {
    v[i].clear();
  }
  for (long long i = 1; i < n + 1; i++) {
    long long x;
    cin >> x;
    v[x].push_back(i);
  }
  vector<long long> pr(n + 5, n + 1);
  for (long long i = 1; i < n + 1; i++) {
    if (v[i].empty()) {
      ans[i] = n + 1;
    } else {
      ans[i] = max(v[i][0], n - v[i].back() + 1);
      for (long long j = 1; j < v[i].size(); j++) {
        amax(ans[i], v[i][j] - v[i][j - 1]);
      }
    }
    amin(pr[ans[i]], i);
  }
  for (long long i = 2; i < n + 1; i++) {
    amin(pr[i], pr[i - 1]);
  }
  for (long long i = 1; i < n + 1; i++) {
    if (pr[i] == n + 1) pr[i] = -1;
    cout << pr[i] << " ";
  }
  cout << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
