#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0, to = n; i < to; i++) cin >> v[i];
  map<int, int> ini;
  for (int i = 0, to = n; i < to; i++) ini[v[i]] = -1;
  map<int, int> maxi;
  for (int i = 0, to = n; i < to; i++) maxi[v[i]] = 0;
  for (int i = 0, to = n; i < to; i++) {
    int last = ini[v[i]];
    int d = i - last - 1;
    maxi[v[i]] = max(maxi[v[i]], d);
    ini[v[i]] = i;
  }
  for (pair<long long, long long> x : maxi) {
    int val = x.first;
    int last = ini[val];
    int d = n - last - 1;
    maxi[val] = max(maxi[val], d);
  }
  vector<int> ans(n, -1);
  int pos = n - 1;
  for (pair<long long, long long> x : maxi) {
    int val = x.first;
    while (pos >= maxi[val]) {
      ans[pos--] = val;
    }
  }
  for (int i = 0, to = n; i < to; i++)
    cout << ans[i] << (char)(i + 1 == n ? 10 : 32);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
