#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int n, m;
int ans[N];
vector<int> v[N];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    int a;
    for (int i = 0; i <= n; i++) ans[i] = 1e9;
    for (int i = 1; i <= n; i++) v[i].clear();
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a);
      v[a].push_back(i);
    }
    int Max = 0;
    for (int i = 1; i <= n; i++) {
      Max = 0;
      for (int j = 0; j < v[i].size(); j++) {
        if (j == 0) Max = max(Max, v[i][j] - 0);
        if (j == v[i].size() - 1)
          Max = max(Max, n + 1 - v[i][j]);
        else if (j != 0)
          Max = max(Max, max(v[i][j] - v[i][j - 1], v[i][j + 1] - v[i][j]));
      }
      if (v[i].size() >= 2)
        Max = max(Max, v[i][v[i].size() - 1] - v[i][v[i].size() - 2]);
      if (Max != 0) ans[Max] = min(ans[Max], i);
    }
    for (int i = 1; i <= n; i++) {
      ans[i] = min(ans[i - 1], ans[i]);
      if (ans[i] != 1e9)
        printf("%d ", ans[i]);
      else
        printf("-1 ");
    }
    puts("");
  }
  return 0;
}
