#include <bits/stdc++.h>
using namespace std;
const long long N = 6e5 + 4;
long long n, t, x, i, val[N], res[N], tmp[N];
signed main() {
  ios::sync_with_stdio(0), cin.tie(nullptr);
  for (cin >> t; t; --t) {
    for (cin >> n, i = 1; i <= n; ++i) tmp[i] = val[i] = 0, res[i] = -1;
    for (i = 1; i <= n && cin >> x; ++i)
      val[x] = max(val[x], i - 1 - tmp[x]), tmp[x] = i;
    for (i = 1; i <= n; ++i) val[i] = max(val[i], n - tmp[i]) + 1;
    for (i = 1, x = n; i <= n; ++i)
      while (x >= 1 && val[i] <= x) res[x] = i, --x;
    for (i = 1; i <= n; ++i) cout << res[i] << (i == n ? '\n' : ' ');
  }
  return 0;
}
