#include <bits/stdc++.h>
using namespace std;
bool comp(pair<int, int> p1, pair<int, int> p2) {
  if (p1.first < p2.first)
    return true;
  else if (p1.first == p2.first && p1.second < p2.second)
    return true;
  else
    return false;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, a;
    cin >> n;
    vector<pair<int, int>> v;
    for (int i = 1; i <= n; i++) {
      cin >> a;
      v.push_back({a, i});
    }
    sort(v.begin(), v.end(), comp);
    int i = 0, j;
    int dp[n + 1];
    for (int i = 0; i <= n; i++) dp[i] = -1;
    for (j = 1; j < n; j++) {
      if (v[j].first != v[j - 1].first) {
        int max1 = -1;
        if (v[i].second != 1) max1 = v[i].second;
        for (int k = i + 1; k < j; k++) {
          max1 = max(v[k].second - v[k - 1].second, max1);
        }
        if (v[j - 1].second != n) max1 = max(max1, n + 1 - v[j - 1].second);
        if (dp[max1] == -1) dp[max1] = v[i].first;
        i = j;
      }
    }
    int max1 = -1;
    if (v[i].second != 1) max1 = v[i].second;
    for (int k = i + 1; k < j; k++) {
      max1 = max(v[k].second - v[k - 1].second, max1);
    }
    if (v[j - 1].second != n) max1 = max(max1, n + 1 - v[j - 1].second);
    if (dp[max1] == -1) dp[max1] = v[i].first;
    max1 = -1;
    for (i = 1; i <= n; i++) {
      if (max1 > 0 && dp[i] > 0)
        max1 = min(max1, dp[i]);
      else if (dp[i] > 0)
        max1 = dp[i];
      dp[i] = max1;
    }
    for (i = 1; i <= n; i++) cout << dp[i] << " ";
    cout << endl;
  }
  return 0;
}
