#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1000000000;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  for (; t; --t) {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> lastpos(n + 1, -1);
    vector<pair<int, int>> ans(n + 1, {-1, n});
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      ans[i].second = i;
    }
    for (int i = 0; i < n; ++i) {
      int cur = a[i];
      ans[cur].first = max(ans[cur].first, (i - lastpos[cur]));
      lastpos[cur] = i;
    }
    for (int i = 0; i < n; ++i) {
      int cur = a[i];
      ans[cur].first = max(ans[cur].first, n - lastpos[cur]);
    }
    vector<int> k(n + 1, inf);
    for (int i = 0; i < n; ++i) {
      int cur = a[i];
      int d = ans[cur].first;
      k[d] = min(k[d], cur);
    }
    for (int i = 1; i < n + 1; i++) {
      k[i] = min(k[i], k[i - 1]);
      cout << (k[i] == inf ? -1 : k[i]) << " ";
    }
    cout << "\n";
  }
  return 0;
}
