#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int pre[N];
int dis[N];
int ans[N];
int main() {
  int TT;
  scanf("%d", &TT);
  while (TT--) {
    int n;
    scanf("%d", &n);
    int x;
    memset(pre, -1, sizeof(int) * (n + 1));
    memset(dis, -1, sizeof(int) * (n + 1));
    memset(ans, -1, sizeof(int) * (n + 1));
    for (int i = 0; i < n; i++) {
      scanf("%d", &x);
      dis[x] = max(i - pre[x], dis[x]);
      pre[x] = i;
    }
    for (int x = 1; x <= n; x++) {
      if (pre[x] != -1) dis[x] = max(n - pre[x], dis[x]);
    }
    int pos = n + 1;
    for (int x = 1; x <= n; x++) {
      if (dis[x] == -1) continue;
      if (dis[x] < pos) {
        for (int i = dis[x]; i < pos; i++) ans[i] = x;
        pos = dis[x];
      }
      if (pos == 1) break;
    }
    for (int i = 1; i <= n; i++) {
      printf("%d%c", ans[i], i == n ? '\n' : ' ');
    }
  }
}
