#include <bits/stdc++.h>
using namespace std;
struct st {
  int x, id;
} a[500010];
int n, maxn, ans[500010], T;
bool cmp(st a, st b) {
  if (a.x == b.x) return a.id < b.id;
  return a.x > b.x;
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i].x);
      a[i].id = i;
    }
    memset(ans, -1, sizeof(ans));
    sort(a + 1, a + 1 + n, cmp);
    for (int i = n; i >= 1; i--) {
      maxn = (n + 1) - a[i].id;
      while (a[i - 1].x == a[i].x) {
        maxn = max(maxn, a[i].id - a[i - 1].id);
        i--;
      }
      maxn = max(maxn, a[i].id);
      for (int j = maxn; j >= 1; j++) {
        if (ans[j] != -1) break;
        ans[j] = a[i].x;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (ans[i] == -1)
        printf("-1 ");
      else
        printf("%d ", ans[i]);
    }
    printf("\n");
  }
  return 0;
}
