#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long i, j, n, x, m, diff, req[300005] = {0}, ans[300005] = {0},
                                   ara[300005] = {0};
    cin >> n;
    for (i = 0; i <= n; i++) {
      ans[i] = -1;
    }
    for (i = 1; i <= n; i++) {
      cin >> x;
      diff = i - ara[x];
      ara[x] = i;
      req[x] = max(req[x], diff);
    }
    for (i = 0; i <= n; i++) {
      diff = n + 1 - ara[i];
      req[i] = max(req[i], diff);
    }
    for (i = n; i >= 1; i--) {
      ans[req[i]] = i;
    }
    x = -1;
    for (i = 1; i <= n; i++) {
      if (ans[i] > x && x != -1) ans[i] = x;
      if (ans[i] != -1) x = ans[i];
      ans[i] = x;
    }
    for (i = 1; i <= n; i++) cout << ans[i] << " ";
    cout << endl;
  }
  return 0;
}
