#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, x, t, c = 0, tc, m, k, s;
  cin >> tc;
  while (tc--) {
    cin >> n;
    int64_t a[n + 10], b[n + 10];
    memset(b, 0, sizeof(b));
    map<int64_t, int64_t> p;
    map<int64_t, int64_t> q;
    map<int64_t, int64_t> l;
    map<int64_t, int64_t> d;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      q[a[i]]++;
    }
    for (int64_t i = 1; i <= n; i++) {
      p[a[i]]++;
      if (q[a[i]] == p[a[i]]) {
        if (p[a[i]] == 1) {
          x = (n + 1) - i;
          l[a[i]] = max(i, x);
        } else {
          x = (n + 1) - i;
          l[a[i]] = max(l[a[i]], (i - d[a[i]]));
          l[a[i]] = max(l[a[i]], x);
        }
        t = l[a[i]];
        if (b[t] == 0) {
          b[t] = n + 10;
        }
        b[t] = min(a[i], b[t]);
      } else {
        l[a[i]] = max(l[a[i]], (i - d[a[i]]));
      }
      d[a[i]] = i;
    }
    for (int i = 1; i <= n; i++) {
      if (b[i] == 0) {
        if (b[i - 1] != 0) {
          b[i] = b[i - 1];
        } else {
          b[i] = -1;
        }
      } else {
        if (b[i - 1] < b[i] && b[i - 1] != -1 && b[i - 1] != 0) {
          b[i] = b[i - 1];
        }
      }
      cout << b[i] << " ";
    }
    cout << endl;
  }
}
