#include <bits/stdc++.h>
#pragma GCC optimize(3)
using namespace std;
const int Mod = 1e9 + 7;
const int N = 3e5 + 100;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
inline long long dpow(long long a, long long b) {
  long long r = 1, t = a;
  while (b) {
    if (b & 1) r = (r * t) % Mod;
    b >>= 1;
    t = (t * t) % Mod;
  }
  return r;
}
inline long long fpow(long long a, long long b) {
  long long r = 1, t = a;
  while (b) {
    if (b & 1) r = (r * t);
    b >>= 1;
    t = (t * t);
  }
  return r;
}
int a[N], ans[N], n;
int mx[N], lst[N];
void Init() {
  for (int i = 1; i <= n; i++) mx[i] = lst[i] = ans[i] = 0;
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    scanf("%d", &n);
    Init();
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      mx[a[i]] = max(mx[a[i]], i - lst[a[i]]);
      lst[a[i]] = i;
    }
    for (int i = 1; i <= n; i++)
      if (lst[i]) mx[i] = max(mx[i], n + 1 - lst[i]);
    int r = n;
    for (int i = 1; i <= n; i++) {
      if (!lst[i]) continue;
      int j;
      for (j = mx[i]; j <= r; j++) ans[j] = i;
      r = min(r, mx[i] - 1);
    }
    for (int i = 1; i <= n; i++) {
      if (!ans[i])
        printf("-1 ");
      else
        printf("%d ", ans[i]);
    }
    puts("");
  }
  return 0;
}
