#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
const int INF = 0x3f3f3f3f;
const int NEG = 0xc0c0c0c0;
const int mov[4][2] = {-1, 0, 0, -1, 0, 1, 1, 0};
void solve() {
  int N;
  cin >> N;
  vector<vector<int>> vt(N + 1);
  for (int i = 0, x; i < N; ++i) {
    cin >> x;
    vt[x].emplace_back(i);
  }
  vector<int> ans(N + 1, -1);
  for (int i = N; i; --i) {
    if (vt[i].empty()) continue;
    vt[i].emplace_back(N);
    adjacent_difference(vt[i].begin(), vt[i].end(), vt[i].begin());
    ++vt[i].front();
    int mx = *max_element(vt[i].begin(), vt[i].end());
    ans[mx] = i;
  }
  cout << ans[1];
  for (int i = 2, x = ans[1]; i <= N; ++i) {
    if (x == -1)
      x = ans[i];
    else if (~ans[i])
      x = min(x, ans[i]);
    cout << ' ' << x;
  }
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) solve();
  return 0;
}
