#include <bits/stdc++.h>
using namespace std;
long long int dp[400009];
long long int dp1[500009];
long long int a[400009];
long long int aa[400009];
long long int c[500009];
long long int ans2[400009];
int main() {
  long long int T, T1;
  cin >> T;
  for (T1 = 1; T1 <= T; T1++) {
    long long int n, i, j, k, p, k1;
    cin >> n;
    k1 = 1;
    for (i = 1; i <= n; i++) {
      cin >> aa[i];
      c[aa[i]]++;
      if (c[aa[i]] == 1) {
        a[k1] = aa[i];
        k1++;
      }
    }
    for (i = 1; i < k1; i++) dp[a[i]] = 0;
    for (i = 1; i < k1; i++) dp1[a[i]] = -2e18;
    for (i = 1; i <= n; i++) {
      p = i - dp[aa[i]];
      dp[aa[i]] = i;
      p--;
      dp1[aa[i]] = max(dp1[aa[i]], p);
    }
    for (i = 1; i < k1; i++) {
      p = (n + 1) - dp[a[i]];
      p--;
      dp1[a[i]] = max(dp1[a[i]], p);
    }
    sort(a + 1, a + k1);
    k = 1;
    long long int k2;
    k2 = n;
    for (i = n; i >= 1; i--) {
      for (; k < k1; k++) {
        if (dp1[a[k]] < i) break;
      }
      if (k >= k1)
        ans2[k2] = -1;
      else
        ans2[k2] = a[k];
      k2--;
    }
    for (i = 1; i <= n; i++) cout << ans2[i] << " ";
    cout << endl;
    for (i = 1; i < k1; i++) c[a[i]] = 0;
  }
}
