/*
Author- Aasav Badera
Time- Wed Sep 30 10:59:00 2020
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL
#include <sys/resource.h>
#define meminc             rlimit rlim;if (getrlimit(RLIMIT_STACK, &rlim)) return 1;rlim.rlim_cur = 268435456;if (setrlimit(RLIMIT_STACK, &rlim)) return 2;
#else
#define meminc
#endif
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 int
#define vi                 vector<int >
#define ordered_set        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define rep(i, a, b)       for(int  i=a;i<b;i++)
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (int )x.size()
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define endl               '\n'
// const int hell = (int)998244353;
const int hell = (int)1e9 + 7;
const long long int inf = 3223372036854775807;
const double PI = 3.14159265;
const int N = (int) 1e6 + 5;
int n, m, k, a[N];

struct item{
    // int m, c;
    // long long int su;
    // long long int mex, pref, suf, sum;
    int val;
    // override assignment operator and default constructor and also remember to override + operator to get merge operation sorted.
    item(){
        val = hell;
    }
    item(int ok)
    {
        val = ok;
    }
    item operator+(const item &op1)
    {
        item ret;
        ret.val = min(op1.val ,val);
        return ret;
    }
};
//O(N) preprocessing time and O(logN) query time amortized.
// take care this implementation is 0 indexed!
// segtree st;
// st.init(n);
// st.build(v);
template<class itemType, class B>
struct segtree{
    int sz;
    vector<itemType> values;
    itemType NEUTRAL_ELEMENT;
    itemType merge(itemType fi, itemType se)
    {
        // if(fi.m < se.m)
        // {
        //     return fi;
        // }
        // if(fi.m > se.m)
        // {
        //     return se;
        // }
        // return {fi.m, fi.c + se.c};
        // return {min(fi.su, se.su)};
        // return {
        //     max({fi.mex ,se.mex ,fi.suf + se.pref}),
        //     max({fi.pref, fi.sum + se.pref}),
        //     max({se.suf, se.sum + fi.suf}),
        //     fi.sum + se.sum
        // };
        return {fi.val + se.val};
    }

    itemType single(B val)
    {
        // if(val > 0)return {val, val, val, val};
        // return {0, 0 , 0, val};
        return {val};
    }
    inline int ri(int _gg){return _gg * 2 + 2;}
    inline int le(int _gg){return _gg * 2 + 1;}
    void init(int new_size)
    {
        sz = 1;
        while(sz < new_size)sz <<= 1;
        values.resize(sz << 1);
    }
    void build(vector<B> &v, int x, int lx, int rx)
    {
        if(rx - lx == 1)
        {
            if(lx < sz(v))
            {
                values[x] = v[lx];
            }
            return ;
        }
        int mx = (lx + rx) >> 1;
        build(v, le(x), lx, mx);
        build(v, ri(x), mx, rx);

        values[x] = values[le(x)] + values[ri(x)];
    }
    void build(vector<B> &v)
    {
        /****************************************************************************/
        // REMEMBER TO CHANGE IT IF OUR FIRST ARGUMENT IS NOT ITEM WHICH IS RARE THO
        // initializing neutral value
        NEUTRAL_ELEMENT = item();
        /*****************************************************************************/
        int _n = v.size();
        init(_n);
        build(v, 0, 0, sz);
    }
    void set(int i, B val, int x, int lx, int rx)
    {
        if(rx - lx == 1)
        {
            values[x] = val;
            return ;
        }
        int mx = (lx + rx) >> 1;
        if(i < mx)
        {
            set(i, val, le(x), lx, mx);
        }
        else
            set(i, val, ri(x), mx, rx);
        values[x] = values[le(x)] + values[ri(x)];
    }
    void set(int i, B val)
    {
        set(i, val, 0, 0, sz);
    }
    itemType calc(int l, int r, int x, int lx, int rx)
    {
        if(lx >= r or l >= rx)return NEUTRAL_ELEMENT;
        if(lx >= l and rx <= r)return values[x];
        int mx = (lx + rx) >> 1;
        itemType f1 = calc(l ,r ,le(x), lx, mx);
        itemType f2 = calc(l ,r ,ri(x), mx, rx);
        return f1 + f2;
    }
    itemType calc(int l, int r)
    {
        return calc(l, r, 0, 0, sz);
    }
};

int32_t main()
{
    meminc;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.precision(10);
    cout.precision(25);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int tests = 1;
    cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n;
        segtree<item, int> st;
        vector<int> v(n, 0);
        st.build(v);
        rep(i, 0, n)cin >> a[i];
        if(n == 1)
        {
        	cout << a[0] << endl;
        	continue;
        }
        int ansyet = -1;
        rep(i, 0, n)
        {
        	k = i + 1;
        	st.set(i, a[i]);
        	int j = k + i;
        	int key = 1;
        	while(j < n and a[j] != a[i])
        	{
        		key = 0;
        		break;
        	}
        	if(key and (ansyet > a[i] or ansyet == -1)){
        		ansyet = a[i];
        	}
        	if(key)
        	{
        		if(k + i < n);
        		else
        		{
        			int ok = st.calc(n - i - 1, i + 1).val;
        			ansyet = min(ansyet, ok);
        		}
        	}
        	cout << ansyet << " ";
        }
        cout << endl;
    }
    #ifdef LOCAL
        // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}


/*
Author- Aasav Badera
Time- Wed Sep 30 10:59:00 2020
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL
#include <sys/resource.h>
#define meminc             rlimit rlim;if (getrlimit(RLIMIT_STACK, &rlim)) return 1;rlim.rlim_cur = 268435456;if (setrlimit(RLIMIT_STACK, &rlim)) return 2;
#else
#define meminc
#endif
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 int
#define vi                 vector<int >
#define ordered_set        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define rep(i, a, b)       for(int  i=a;i<b;i++)
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (int )x.size()
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define endl               '\n'
// const int hell = (int)998244353;
const int hell = (int)1e9 + 7;
const long long int inf = 3223372036854775807;
const double PI = 3.14159265;
const int N = (int) 1e6 + 5;
int n, m, k, a[N];

int32_t main()
{
    meminc;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.precision(10);
    cout.precision(25);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int tests = 1;
    cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n;
        rep(i, 0, n)cin >> a[i];
        if(n == 1)
        {
        	cout << a[0] << endl;
        	continue;
        }
        set<int> s[n + 1];
        rep(i, 0, n)s[a[i]].insert(i);
        int ans[n];
        memset(ans, -1, sizeof ans);
        rep(i, 0, n)
        {
        	int sz = i + 1;
        	int j = i + sz;
        	while(j < n)
        	{
        		if(s[a[i]].lower_bound(j - sz + 1) != s[a[i]].end() and s[a[i]].lower_bound(j - sz + 1) != s[a[i]].lower_bound(j - 2 * sz - 1))
        			;
        		else break;
        		j += sz;
        	}
        	if(test == 3)
        	dbg(i, j, sz);
        	if(j < n)
        	{
        		sz = n - sz + 1;
        	}
        	if(ans[sz - 1] == -1)
        	{
        		ans[sz - 1] = a[i];
        	}
        	else
        	{
        		ans[sz - 1] = min(ans[sz - 1], a[i]);
        	}
        }
        rep(i, 1, n + 1)
        {
        	if(ans[i] == -1 and ans[i - 1] != -1)ans[i] = ans[i - 1];
        	else if(ans[i - 1] == -1)continue;
        	ans[i] = min(ans[i], ans[i - 1]);
        }
        rep(i, 0, n)
        {
        	cout << ans[i] << " ";
        }
    	cout << endl;
    }
    #ifdef LOCAL
        // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}


/*
Author- Aasav Badera
Time- Wed Sep 30 13:13:47 2020
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL
#include <sys/resource.h>
#define meminc             rlimit rlim;if (getrlimit(RLIMIT_STACK, &rlim)) return 1;rlim.rlim_cur = 268435456;if (setrlimit(RLIMIT_STACK, &rlim)) return 2;
#else
#define meminc
#endif
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 int
#define vi                 vector<int >
#define ordered_set        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define rep(i, a, b)       for(int  i=a;i<b;i++)
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (int )x.size()
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define endl               '\n'
// const int hell = (int)998244353;
const int hell = (int)1e9 + 7;
const long long int inf = 3223372036854775807;
const double PI = 3.14159265;
const int N = (int) 1e6 + 5;
int n, m, k, a[N];

int32_t main()
{
    meminc;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.precision(10);
    cout.precision(25);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int tests = 1;
    cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n;
        rep(i, 0 ,n)cin >> a[i];
    	vector<int> v[n + 1];
    	rep(i, 0, n)
    	{
    		v[a[i]].push_back(i);
    	}
    	int ans[n + 1];
    	memset(ans, -1, sizeof ans);
    	rep(i, 1, n + 1)
    	{
    		if(!sz(v[i]))continue;
   			int mex = max(n - v[i].back(), v[i][0] + 1);
   			rep(j, 1, sz(v[i]))mex = max(mex, v[i][j] - v[i][j - 1]);
   			if(test == 2)
   			dbg(i, mex);
   			if(ans[mex] == -1)ans[mex] = i;
    	}
    	rep(i, 2, n + 1)
    	{
    		if(ans[i - 1] == -1)continue;
    		if(ans[i] == -1)ans[i] = ans[i - 1];
    		ans[i] = min(ans[i], ans[i - 1]);
    	}
    	rep(i, 1, n + 1)cout << ans[i] << " ";
    	cout << endl;
    }
    #ifdef LOCAL
        // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}


/*
Author- Aasav Badera
Time- Wed Sep 30 10:59:00 2020
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL
#include <sys/resource.h>
#define meminc             rlimit rlim;if (getrlimit(RLIMIT_STACK, &rlim)) return 1;rlim.rlim_cur = 268435456;if (setrlimit(RLIMIT_STACK, &rlim)) return 2;
#else
#define meminc
#endif
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 int
#define vi                 vector<int >
#define ordered_set        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define rep(i, a, b)       for(int  i=a;i<b;i++)
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (int )x.size()
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define endl               '\n'
// const int hell = (int)998244353;
const int hell = (int)1e9 + 7;
const long long int inf = 3223372036854775807;
const double PI = 3.14159265;
const int N = (int) 1e6 + 5;
int n, m, k, a[N];

int32_t main()
{
    meminc;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.precision(10);
    cout.precision(25);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int tests = 1;
    cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n;
        rep(i, 0, n)cin >> a[i];
        if(n == 1)
        {
        	cout << a[0] << endl;
        	continue;
        }
        set<int> s[n + 1];
        rep(i, 0, n)s[a[i]].insert(i);
        int ans[n];
        memset(ans, -1, sizeof ans);
        rep(i, 0, n)
        {
        	int sz = i + 1;
        	int j = i + sz;
        	while(j < n)
        	{
        		if(s[a[i]].lower_bound(j) != s[a[i]].end() and s[a[i]].lower_bound(j) != s[a[i]].lower_bound(j - sz))
        			;
        		else break;
        		j += sz;
        	}
        	if(j < n)
        	{
        		sz = n - sz + 1;
        	}
        	if(ans[sz - 1] == -1)
        	{
        		ans[sz - 1] = a[i];
        	}
        	else
        	{
        		ans[sz - 1] = min(ans[sz - 1], a[i]);
        	}
        }
        rep(i, 1, n + 1)
        {
        	if(ans[i] == -1 and ans[i - 1] != -1)ans[i] = ans[i - 1];
        	else if(ans[i - 1] == -1)continue;
        	ans[i] = min(ans[i], ans[i - 1]);
        }
        rep(i, 0, n)
        {
        	cout << ans[i] << " ";
        }
    	cout << endl;
    }
    #ifdef LOCAL
        // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}


/*
Author- Aasav Badera
Time- Wed Sep 30 10:59:00 2020
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL
#include <sys/resource.h>
#define meminc             rlimit rlim;if (getrlimit(RLIMIT_STACK, &rlim)) return 1;rlim.rlim_cur = 268435456;if (setrlimit(RLIMIT_STACK, &rlim)) return 2;
#else
#define meminc
#endif
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 int
#define vi                 vector<int >
#define ordered_set        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define rep(i, a, b)       for(int  i=a;i<b;i++)
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (int )x.size()
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define endl               '\n'
// const int hell = (int)998244353;
const int hell = (int)1e9 + 7;
const long long int inf = 3223372036854775807;
const double PI = 3.14159265;
const int N = (int) 1e6 + 5;
int n, m, k, a[N];

int32_t main()
{
    meminc;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.precision(10);
    cout.precision(25);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int tests = 1;
    cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n;
        rep(i, 0, n)cin >> a[i];
        if(n == 1)
        {
        	cout << a[0] << endl;
        	continue;
        }
        set<int> s[n + 1];
        rep(i, 0, n)s[a[i]].insert(i);
        int ans[n];
        memset(ans, -1, sizeof ans);
        rep(i, 0, n)
        {
        	int sz = i + 1;
        	int j = i + sz;
        	while(j < n)
        	{
        		if(s[a[i]].lower_bound(j - 1) != s[a[i]].end() and s[a[i]].lower_bound(j - 1) != s[a[i]].lower_bound(j - sz - 1))
        			;
        		else break;
        		j += sz;
        	}
        	if(test == 3)
        	dbg(i, j, sz);
        	if(j < n)
        	{
        		sz = n - sz + 1;
        	}
        	if(ans[sz - 1] == -1)
        	{
        		ans[sz - 1] = a[i];
        	}
        	else
        	{
        		ans[sz - 1] = min(ans[sz - 1], a[i]);
        	}
        }
        rep(i, 1, n + 1)
        {
        	if(ans[i] == -1 and ans[i - 1] != -1)ans[i] = ans[i - 1];
        	else if(ans[i - 1] == -1)continue;
        	ans[i] = min(ans[i], ans[i - 1]);
        }
        rep(i, 0, n)
        {
        	cout << ans[i] << " ";
        }
    	cout << endl;
    }
    #ifdef LOCAL
        // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}


/*
Author- Aasav Badera
Time- Wed Sep 30 10:59:00 2020
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL
#include <sys/resource.h>
#define meminc             rlimit rlim;if (getrlimit(RLIMIT_STACK, &rlim)) return 1;rlim.rlim_cur = 268435456;if (setrlimit(RLIMIT_STACK, &rlim)) return 2;
#else
#define meminc
#endif
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 int
#define vi                 vector<int >
#define ordered_set        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define rep(i, a, b)       for(int  i=a;i<b;i++)
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (int )x.size()
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define endl               '\n'
// const int hell = (int)998244353;
const int hell = (int)1e9 + 7;
const long long int inf = 3223372036854775807;
const double PI = 3.14159265;
const int N = (int) 1e6 + 5;
int n, m, k, a[N];

int32_t main()
{
    meminc;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.precision(10);
    cout.precision(25);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int tests = 1;
    cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n;
        rep(i, 0, n)cin >> a[i];
        if(n == 1)
        {
        	cout << a[0] << endl;
        	continue;
        }
        set<int> s[n + 1];
        rep(i, 0, n)s[a[i]].insert(i);
        int ans[n];
        memset(ans, -1, sizeof ans);
        rep(i, 0, n)
        {
        	int sz = i + 1;
        	int j = sz;
        	while(j < n)
        	{
        		if(s[a[i]].lower_bound(j - 1) != s[a[i]].end() and s[a[i]].lower_bound(j - 1) != s[a[i]].lower_bound(j - sz - 1))
        			;
        		else break;
        		j += sz;
        	}
        	if(test == 1)
        	dbg(i, j, sz);
        	if(j < n)
        	{
        		sz = max(sz, n - sz + 1);
        	}
        	if(ans[sz - 1] == -1)
        	{
        		ans[sz - 1] = a[i];
        	}
        	else
        	{
        		ans[sz - 1] = min(ans[sz - 1], a[i]);
        	}
        }
        rep(i, 1, n + 1)
        {
        	if(ans[i] == -1 and ans[i - 1] != -1)ans[i] = ans[i - 1];
        	else if(ans[i - 1] == -1)continue;
        	ans[i] = min(ans[i], ans[i - 1]);
        }
        rep(i, 0, n)
        {
        	cout << ans[i] << " ";
        }
    	cout << endl;
    }
    #ifdef LOCAL
        // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

using ll = long long;
using ull = unsigned long long;

void test_case() {
	ll n;

	cin >> n;

	vector<ll> last_num_index(n+1, -1);
	vector<ll> num_max_difference(n+1, -1);

	for (ll i = 0; i < n; i++) {
		ll next;
		cin >> next;

		num_max_difference[next] = max(num_max_difference[next], i-last_num_index[next]);

		last_num_index[next] = i;
	}

	for (ll i = 0; i < n; i++) {
		num_max_difference[i] = max(num_max_difference[i], n - last_num_index[i]);
	}

	vector<ll> answer(n+1);
	ll current_min_num = 0;

	for (ll i = n; i > 0; i--) {
		while (current_min_num != n + 1 && (num_max_difference[current_min_num] == -1 || num_max_difference[current_min_num] > i)) {
			current_min_num++;
		}

		if (current_min_num == n + 1)  answer[i] = -1;
		else answer[i] = current_min_num;
	}

	for (ll i = 1; i < n+1; i++) {
		cout << answer[i] << " ";
	}

	cout << endl;
}

int main()
{
	ll t;
	cin >> t;
	while (t) {
		test_case();
		t--;
	}
}


#include <cstdlib>
#include <string>
#include <iostream>
#include <vector>
#include <map>
#include <random>
#include <algorithm>
#include <set>

using namespace std;

int32_t main()
{
	int t, n;
	cin >> t;
	while (t)
	{
		cin >> n;
		vector<int> a(n);
		map<int, vector<int>> m;
		for (int i = 0; i < n; i++)
		{
			cin >> a[i];
			if (m.find(a[i]) == m.end())
			{
				m[a[i]].push_back(-1);
			}
			m[a[i]].push_back(i);
		}
		map<int, vector<int>>::iterator it;

		for (it = m.begin(); it != m.end(); it++)
		{
			it->second.push_back(n);
		}

		map<int, int> max_diff;
		for (it = m.begin(); it != m.end(); it++)
		{
			int max_d = -1;
			vector<int> places = it->second;
			for (int i = 0; i < places.size() - 1; i++)
			{
				if (places[i + 1] - places[i] > max_d)
					max_d = places[i + 1] - places[i];
			}
			max_diff[it->first] = max_d;
		}

		vector<int> res(n, -1);
		map<int, int>::iterator it2;
		int k = n;
		for (it2 = max_diff.begin(); it2 != max_diff.end(); it2++)
		{
			int max_d = it2->second;
			int num = it2->first;
			while (max_d <= k)
			{
				res[k - 1] = num;
				k--;
			}
		}
		for (int i = 0; i < n; i++)
		{
			cout << res[i] << " ";
		}
		cout << endl;
		t--;
	}
	return 0;

}


#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>

using namespace std;

int main()
{
	int t;
	cin >> t;
	for (int _ = 0; _ < t; _++)
	{
		int n;
		cin >> n;
		vector<int> a(n);
		for (int i = 0; i < n; i++)
			cin >> a[i];

		vector<vector<int>> e(n + 1); // e[i] == a[j] -->  { i1, i2, i3, .... }
		for (int i = 0; i < n; i++)
		{
			e[a[i]].push_back(i);
		}

		vector<int> max_dist(n + 1, -1); // a[i] -> max distance
		for (int i = 0; i < n + 1; i++)
		{
			if (!e[i].empty())
			{
				int m = e[i].size();
				int fir = e[i][0],
					las = e[i][m - 1];
				for (int j = 1; j < m; j++)
					max_dist[i] = max(max_dist[i], e[i][j] - e[i][j - 1]);

				max_dist[i] = max(fir - (-1), max(max_dist[i], n - las));
			}
		}
		vector<int> res(n + 1, -1);
		for (int i = 0; i < n + 1; i++)
		{
			if (max_dist[i] == -1)
				continue;

			int j = max_dist[i];
			if (res[j] != -1)
				res[j] = min(i, res[j]);
			else
				res[j] = i;
		}

		int las_val = -1;
		for (int i = 1; i < n + 1; i++)
		{
			if (res[i] != -1)
			{
				if (las_val == -1)
					las_val = res[i];
				else
					las_val = min(res[i], las_val);
			}
			cout << las_val << ' ';
		}
		cout << '\n';
	}

	return 0;
}


#include<iostream>
using namespace std;
const int maxn=3e5+100;
const int inf=0x3f3f3f3f;
int dist[maxn];
int pre[maxn];
int dp[maxn];
int arr[maxn];
int main()
{
	int t;
	cin>>t;
	while (t--)
	{
		int n;
		cin>>n;
		for (int i=1;i<=n;i++)
			cin>>arr[i];
		for (int i=1;i<=n;i++)
		{
			pre[i]=0;
			dist[i]=-1;
			dp[i]=inf;
		}
		for (int i=1;i<=n;i++)
		{
			dist[arr[i]]=max(dist[arr[i]],i-pre[arr[i]]);
			pre[arr[i]]=i;
		}
		for (int i=1;i<=n;i++)
		{
			dist[arr[i]]=max(dist[arr[i]],n+1-pre[arr[i]]);
		}
		for (int i=1;i<=n;i++)
		{
			if (dist[i]==-1)
				continue;
			else
			{
				dp[dist[i]]=min(i,dp[dist[i]]);
			}
		}
		int z;
		for (z=1;z<=n;z++)
		{
			if (dp[z]!=inf)
				break;
			else
				dp[z]=-1;
		}
		for (int i=z+1;i<=n;i++)
		{
			dp[i]=min(dp[i],dp[z]);
		}
		for (int i=1;i<=n;i++)
			cout<<dp[i]<<" ";
		cout<<endl;
	}
}


#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=3e5+100;
const int inf=0x3f3f3f3f;
int dist[maxn];
int pre[maxn];
int dp[maxn];
int arr[maxn];
int main()
{
	//freopen("food.in","r",stdin);
	//freopen("food.out","w",stdout);
	int t;
	cin>>t;
	while (t--)
	{
		int n;
		cin>>n;
		for (int i=1;i<=n;i++)
			cin>>arr[i];
		for (int i=1;i<=n;i++)
		{
			pre[i]=0;
			dist[i]=-1;
			dp[i]=inf;
		}
		for (int i=1;i<=n;i++)
		{
			dist[arr[i]]=max(dist[arr[i]],i-pre[arr[i]]);
			pre[arr[i]]=i;
		}
		for (int i=1;i<=n;i++)
		{
			dist[arr[i]]=max(dist[arr[i]],n+1-pre[arr[i]]);
		}
		for (int i=1;i<=n;i++)
		{
			if (dist[i]==-1)
				continue;
			else
			{
				dp[dist[i]]=min(i,dp[dist[i]]);
			}
		}
		int z;
		for (z=1;z<=n;z++)
		{
			if (dp[z]!=inf)
				break;
			else
				dp[z]=-1;
		}
		for (int i=z+1;i<=n;i++)
		{
			dp[i]=min(dp[i],dp[z]);
			z=i;
		}
		for (int i=1;i<=n;i++)
			cout<<dp[i]<<" ";
		cout<<endl;
	}
}


#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=3e5+100;
const int inf=0x3f3f3f3f;
int dist[maxn];
int pre[maxn];
int dp[maxn];
int arr[maxn];
int main()
{
	int t;
	cin>>t;
	while (t--)
	{
		int n;
		cin>>n;
		for (int i=1;i<=n;i++)
			cin>>arr[i];
		for (int i=1;i<=n;i++)
		{
			pre[i]=0;
			dist[i]=-1;
			dp[i]=inf;
		}
		for (int i=1;i<=n;i++)
		{
			dist[arr[i]]=max(dist[arr[i]],i-pre[arr[i]]);
			pre[arr[i]]=i;
		}
		for (int i=1;i<=n;i++)
		{
			dist[arr[i]]=max(dist[arr[i]],n+1-pre[arr[i]]);
		}
		for (int i=1;i<=n;i++)
		{
			if (dist[i]==-1)
				continue;
			else
			{
				dp[dist[i]]=min(i,dp[dist[i]]);
			}
		}
		int z;
		for (z=1;z<=n;z++)
		{
			if (dp[z]!=inf)
				break;
			else
				dp[z]=-1;
		}
		for (int i=z+1;i<=n;i++)
		{
			dp[i]=min(dp[i],dp[z]);
		}
		for (int i=1;i<=n;i++)
			cout<<dp[i]<<" ";
		cout<<endl;
	}
}


#include <iostream>
#include <fstream>
#include <algorithm>
#include <math.h>
#include <string.h>
#define ll long long

using namespace std;

int t;
int arr[300000];
int nums[300001];
int maxDists[300001];
int ans[300001];

int main() {
	cin >> t;
	for (int i = 0; i < t; i++) {
		for (int j = 0; j < 300001; j++) {
			nums[j] = -1;
		}
		memset(maxDists, 0, sizeof(maxDists));
		memset(ans, 0, sizeof(ans));
		int n;
		cin >> n;
		for (int j = 0; j < n; j++) {
			cin >> arr[j];
			if (j - nums[arr[j]] > maxDists[arr[j]]) {
				maxDists[arr[j]] = j - nums[arr[j]];
			}
			nums[arr[j]] = j;
		}
		for (int j = 0; j < n; j++) {
			if (n - nums[arr[j]] > maxDists[arr[j]]) {
				maxDists[arr[j]] = n - nums[arr[j]];
			}
		}
		int last = -1;
		for (int j = 1; j <= n; j++) {
			if (ans[maxDists[j]] == 0 || ans[maxDists[j]] > j) {
				ans[maxDists[j]] = j;
			}
		}
		for (int j = 1; j <= n; j++) {
			if (ans[j] != 0 && (ans[j] < last || last == -1)) {
				last = ans[j];
			}
			else {
				ans[j] = last;
			}
			if (j != 1) {
				cout << ' ';
			}
			cout << ans[j];
		}
		cout << '\n';
	}
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;

//typedef long long int i64; // 9e18
typedef long long int i64; // 9e18

typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

//const double PI = 3.141592653589793238463;
//const int MAXN = 1000500;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;

i64 T, n, m, k;
//vector <vector<i64>> a;
//vector <i64> b;
//vector <i64> dp;

//vector<i64> v;
vector<bool> used;

i64 start;
i64 pr = 0;

//vector<i64> path;

void dfs(map<i64,set<i64>> &g, set<i64> &p, i64 v) {

    p.insert(v);
    used[v] = true;

    for (auto u : g[v]) {
        if (used[u]) {
            continue;
        }
        dfs(g, p, u);
    }

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(16);

    T = 1;
    cin >> T;

    for (i64 tt = 0; tt < T; ++tt) {

        cin >> n;
        vector<i64> a(n);

        for (i64 i = 0; i < n; ++i) {
            cin >> a[i];
        }

        map<i64, vector<i64>> mp;
        for (i64 i = 0; i < n; ++i) {
            if (mp.count(a[i])) {
                mp[a[i]].push_back(i);
            }
            else {
                mp[a[i]] = { i };
            }
        }

        map<i64, i64> dist;

        for (i64 i = 1; i <= n; ++i) {
            if (!mp.count(i)) {
                continue;
            }
            i64 st = -1;
            i64 fn = mp[i].size();
            i64 d = 0;
            for (i64 j = 0; j < fn; ++j) {
                if (mp[i][j] - st > d) {
                    d = mp[i][j] - st;
                }
                st = mp[i][j];
            }
            if (n - st > d) {
                d = n - st;
            }
            dist[i] = d;

        }

        map<i64, i64>r;

        for (auto d : dist) {
            if (r.count(d.second)) {
                i64 y = d.first;
                if (y < r[d.second]) {
                    r[d.second] = y;
                }
            }
            else {
                r[d.second] = d.first;
            }
        }

        i64 r0 = -1;
        for (i64 i = 1; i <= n; ++i) {
            if (r.count(i)) {
                if (r0 == -1) {
                    r0 = r[i];
                }
                else {
                    if (r[i] < r0) {
                        r0 = r[i];
                    }
                }
            }
            cout << r0 << ' ';
        }
        cout << endl;

    }
        return 0;
}


#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;

//typedef long long int i64; // 9e18
typedef long long int i64; // 9e18

typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

//const double PI = 3.141592653589793238463;
//const int MAXN = 1000500;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;

i64 T, n, m, k;
//vector <vector<i64>> a;
//vector <i64> b;
//vector <i64> dp;

//vector<i64> v;
vector<bool> used;

i64 start;
i64 pr = 0;

//vector<i64> path;

void dfs(map<i64,set<i64>> &g, set<i64> &p, i64 v) {

    p.insert(v);
    used[v] = true;

    for (auto u : g[v]) {
        if (used[u]) {
            continue;
        }
        dfs(g, p, u);
    }

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(16);

    T = 1;
    cin >> T;

    for (i64 tt = 0; tt < T; ++tt) {

        cin >> n;
        vector<i64> a(n);

        for (i64 i = 0; i < n; ++i) {
            cin >> a[i];
        }

        map<i64, vector<i64>> mp;
        for (i64 i = 0; i < n; ++i) {
            if (mp.count(a[i])) {
                mp[a[i]].push_back(i);
            }
            else {
                mp[a[i]] = { i };
            }
        }

        map<i64, i64> dist;

        for (i64 i = 1; i <= n; ++i) {
            if (!mp.count(i)) {
                continue;
            }
            i64 st = -1;
            i64 fn = mp[i].size();
            i64 d = 0;
            for (i64 j = 0; j < fn; ++j) {
                if (mp[i][j] - st > d) {
                    d = mp[i][j] - st;
                }
                st = mp[i][j];
            }
            if (n - st > d) {
                d = n - st;
            }
            dist[i] = d;

        }

        i64 ch = 0;
        i64 ki = INF;

        for (auto x : dist) {
            if (x.second < ki) {
                ki = x.second;
                ch = x.first;
            }
        }

        for (i64 i = 1; i <= n; ++i) {
            if (i < ki) {
                cout << "-1 ";
            }
            else {
                cout << ch << ' ';
            }
        }
        cout << endl;

    }
        return 0;
}


// Author   : tik-tok
// Language : C++
// ********************
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <cmath>
#include <bitset>
#include <string>
#include <stdlib.h>
#include <regex>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define readFile  freopen("in.txt","r",stdin)
#define writeFile freopen("out.txt","w",stdout)
#define fastIO ios::sync_with_stdio(0)
#pragma warning(disable : 4996) //_CRT_SECURE_NO_WARNINGS

const int N = 3e5 + 6;
vector<int> inds[N];
int res[N];

int main() {

#ifndef ONLINE_JUDGE
	readFile;
	//writeFile;
#endif;

	fastIO;
	int t;	cin >> t;
	while (t--) {
		int n;	cin >> n;
		for (int i = 1; i <= n; i++) {
			res[i] = -1;
			inds[i].clear();
		}

		for (int i = 1; i <= n; i++) {
			ll x;	cin >> x;
			inds[x].push_back(i);
		}

		vector<int> v(n + 1);
		for (int i = 1; i <= n; i++) {
			if (inds[i].size() == 0)
				v[i] = -1;

			for (int j = 0; j < inds[i].size(); j++) {
				if (j == 0)
					v[i] = max(v[i], inds[i][j]);

				if (j == inds[i].size()-1)
					v[i] = max(v[i], n - inds[i][j] + 1);

				if (j > 0)
					v[i] = max(v[i], inds[i][j] - inds[i][j-1]);
			}
		}

		int mn = n + 1;
		for (int i = 1; i <= n; i++) {
			if (v[i] != -1 && v[i] < mn) {
				for (int j = v[i]; j < mn; j++)
					res[j] = i;
				mn = v[i];
			}

		}

		for (int i = 1; i <= n; i++)
			cout << res[i] << " ";
		cout << endl;
	}

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:10000000000")
//#pragma GCC optimize("O3")
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include<iomanip>
#include <cstring>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define fr(i, l, r) for(int i = l; i < r; ++i)
#define rf(i, r, l) for(int i = r; i > l; --i)
#define fr_au(i, l, r) for(auto i = l; i != r; ++i)
#define len(a) a.size()
#define elif else if
#define mp make_pair
#define pb push_back
//#define or ||
//#define and &&

ll inf = 1000000007, t;
double eps = 0.00000001;
int n, v, k, mn;
vector <pair<int, int> > vec;
map <int, vector<int> > sl;
map <int, int > pos;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%lld", &t);
	fr(qwerty, 0, t) {
		scanf("%d", &n);
		mn = 0;
		sl.clear();
		pos.clear();
		vec.clear();
		fr(i, 0, n) {
			scanf("%d", &v);
			if (sl.find(v) != sl.end()) {
				sl[v].pb(i - pos[v]);
				pos[v] = i;
			}
			else {
				sl[v].pb(i + 1);
				pos[v] = i;
			}
		}
		fr_au(i, sl.begin(), sl.end()) {
			sl[(*i).first].pb(n - pos[(*i).first]);
		}
		pos.clear();
		fr_au(i, sl.begin(), sl.end()) {
			sort((*i).second.begin(), (*i).second.end());
			if (pos.find((*i).second[len((*i).second) - 1]) == pos.end()) {
				pos[(*i).second[len((*i).second) - 1]] = (*i).first;
				vec.pb(mp((*i).second[len((*i).second) - 1], (*i).first));
			}
		}
		int j = 0;
		v = 0;
		sort(vec.begin(), vec.end());
		while (j < n) {
			if (v < vec.size()) {
				if (vec[v].first <= j + 1) {
					if (v + 1 < vec.size()) {
						if (vec[v + 1].first <= j + 1 && vec[v + 1].second < vec[v].second)
							++v;
					}
					printf("%d ", vec[v].second);
				}
				elif (vec[v].first > j + 1) {
					if (v - 1 > -1) {
						printf("%d ", vec[v].second);
					}
					else {
						printf("-1 ");
					}
				}

			}
			++j;
		}
		printf("\n");
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:10000000000")
//#pragma GCC optimize("O3")
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <math.h>
#include<iomanip>
#include <cstring>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define fr(i, l, r) for(int i = l; i < r; ++i)
#define rf(i, r, l) for(int i = r; i > l; --i)
#define fr_au(i, l, r) for(auto i = l; i != r; ++i)
#define len(a) a.size()
#define elif else if
#define mp make_pair
#define pb push_back
//#define or ||
//#define and &&

ll inf = 1000000007, t;
double eps = 0.00000001;
int n, v, k, mn, m;
vector <pair<int, int> > vec;
map <int, vector<int> > sl;
map <int, int > pos;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	scanf("%lld", &t);
	fr(qwerty, 0, t) {
		scanf("%d", &n);
		mn = 0;
		sl.clear();
		pos.clear();
		vec.clear();
		fr(i, 0, n) {
			scanf("%d", &v);
			if (sl.find(v) != sl.end()) {
				sl[v].pb(i - pos[v]);
				pos[v] = i;
			}
			else {
				sl[v].pb(i + 1);
				pos[v] = i;
			}
		}
		fr_au(i, sl.begin(), sl.end()) {
			sl[(*i).first].pb(n - pos[(*i).first]);
		}
		pos.clear();
		fr_au(i, sl.begin(), sl.end()) {
			sort((*i).second.begin(), (*i).second.end());
			if (pos.find((*i).second[len((*i).second) - 1]) == pos.end()) {
				pos[(*i).second[len((*i).second) - 1]] = (*i).first;
				vec.pb(mp((*i).second[len((*i).second) - 1], (*i).first));
			}
		}
		int j = 0;
		v = 0;
		m = 1;
		sort(vec.begin(), vec.end());
		while (j < n) {
			if (v < vec.size()) {
				if (vec[v].first <= j + 1) {
					if (m < vec.size()) {
						if (vec[m].first <= j + 1 && vec[m].second < vec[v].second) {
							v = m;
							++m;
						}
						while (m < vec.size()) {
							if (vec[m].first <= j + 1 && vec[m].second >= vec[v].second) {
								++m;
							}
							else {
								break;
							}
						}
					}
					printf("%d ", vec[v].second);
				}
				elif (vec[v].first > j + 1) {
					if (v - 1 > -1) {
						printf("%d ", vec[v].second);
					}
					else {
						printf("-1 ");
					}
				}

			}
			++j;
		}
		printf("\n");
	}
	return 0;
}


#include <string>
#include <vector>
#include <iostream>
#include <stdio.h>

using namespace std;

vector<int> search(int n, vector<int> a)
{
	vector<int> b(n + 1);
	vector<int> c(n + 1);
	vector<int> d(n + 1);
	vector<int> answer(n);

	for (int i = 0; i < n; i++)
	{
		b[i + 1] = 0;
		c[i + 1] = -1;
		d[i + 1] = n + 1;
		answer[i] = n + 1;
	}
	for (int i = 0; i < n; i++)
	{
		b[a[i]] = (b[a[i]] > i - c[a[i]]) ? b[a[i]] : i - c[a[i]];
		c[a[i]] = i;
	}
	for (int i = 1; i <= n; i++)
		if (c[i] != -1)
			b[i] = (b[i] > n - c[i]) ? b[i] : n - c[i];
	for (int i = n ; i > 0; i--)
		d[b[i]] = i;
	answer[0] = d[1];
	for (int i = 1; i < n; i++)
	{
			answer[i] = (d[i + 1] > answer[i - 1]) ? answer[i - 1] : d[i + 1];
	}
	for (int i = 0; i < n; i++)
		if (answer[i] == n + 1)
			answer[i] = -1;
	return answer;
}

int main()
{
	int test;
	int n;
	vector<int> a;
	vector<vector<int>> answer;

	cin >> test;
	for (int i = 0; i < test; i++)
	{
		cin >> n;
		a.resize(n);
		for (int i = 0; i < a.size(); i++)
		{
			cin >> a[i];
		}
		answer.push_back(search(n, a));
	}
	for (int i = 0; i < answer.size(); i++)
	{
		for (int j = 0; j < answer[i].size(); j++)
			cout << answer[i][j] << " ";
		cout << endl;
	}
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <bitset>
#include <vector>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <ctime>
#include <cassert>
#include <fstream>
#include <iomanip>
using namespace std;

#define ll int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ma(a,b) a=max(a,b)
#define mi(a,b) a=min(a,b)
#define endl '\n'
# define pi  3.14159265358979323846
#define deb(a) cout<< #a<< " = " << a <<endl;
const int M = 1e5 + 10;
const ll mod = 1000000000 + 9;
const long double epsilon = 1e-12;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("INPUT.TXT", "r", stdin);
	//freopen("OUTPUT.TXT", "w", stdout);
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		map<int, vector<int>>m;
		vector<int>a(n+1);
		a[0] = 0;
		vector<int>answer(n+1, -1);
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
			if (m[a[i]].size() == 0)m[a[i]].push_back(0);
			m[a[i]].push_back(i);
		}
		for (int i = 1; i<=n; i++) {
			if (m[a[i]][0] == 0) {
				int mans = m[a[i]][1];
				for (int j = 2; j < m[a[i]].size(); j++) {
					if (m[a[i]][j] - m[a[i]][j - 1] > mans) mans = m[a[i]][j] - m[a[i]][j - 1];
				}
				m[a[i]][0] = mans;
			}
		}
		sort(a.begin(), a.end());
		a.erase(unique(a.begin(), a.end()), a.end());

		for (int i = 1; i <a.size(); i++) {
			for (int j = max(n - m[a[i]][m[a[i]].size()-1]+1,m[a[i]][0])-1; j <= n && answer[j]==-1; j++) {
				//cout << j << endl;
				answer[j] = a[i];

			}
		}
		for (int i = 0; i < n; i++) {
			cout << answer[i] << " ";
		}
		cout << endl;
	}
	return 0;
}


#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <bitset>
#include <vector>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <ctime>
#include <cassert>
#include <fstream>
#include <iomanip>
using namespace std;

#define ll int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ma(a,b) a=max(a,b)
#define mi(a,b) a=min(a,b)
#define endl '\n'
# define pi  3.14159265358979323846
#define deb(a) cout<< #a<< " = " << a <<endl;
const int M = 1e5 + 10;
const ll mod = 1000000000 + 9;
const long double epsilon = 1e-12;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("INPUT.TXT", "r", stdin);
	//freopen("OUTPUT.TXT", "w", stdout);
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;
		map<int, vector<int>>m;
		vector<int>a(n+1);
		a[0] = 0;
		vector<int>answer(n+1, -1);
		for (int i = 1; i <= n; i++) {
			cin >> a[i];
			if (m[a[i]].size() == 0)m[a[i]].push_back(0);
			m[a[i]].push_back(i);
		}
		for (int i = 1; i<=n; i++) {
			if (m[a[i]][0] == 0) {
				int mans = m[a[i]][1]-1;
				for (int j = 2; j < m[a[i]].size(); j++) {
					if (m[a[i]][j] - m[a[i]][j - 1] > mans) mans = m[a[i]][j] - m[a[i]][j - 1];
				}
				m[a[i]][0] = mans;
			}
		}
		sort(a.begin(), a.end());
		a.erase(unique(a.begin(), a.end()), a.end());

		for (int i = 1; i <a.size(); i++) {
			for (int j = max(n - m[a[i]][m[a[i]].size()-1]+1,m[a[i]][0]); j <= n && answer[j]==-1; j++) {
				//cout << j << endl;
				answer[j] = a[i];

			}
		}
		for (int i = 1; i <= n; i++) {
			cout << answer[i] << " ";
		}
		cout << endl;
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<deque>
#include<map>
#include<unordered_map>
#include<string>
#include<stack>
#include<vector>
#include<set>
#include<iomanip>
#include <cmath>
#include <iterator>
#include <cstdint>
#include <list>
#include <memory>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
#define ll long long
using namespace std;
#define int long long
int a[400000];
int cur[400000];
int v[400000];
void main()
{
#if defined _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	std::ios::sync_with_stdio(false);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	int n;
	for (int i = 0; i < t; i++)
	{
		cin >> n;
		for (int j = 0; j < n; j++)
		{
			cin >> a[j];
			cur[j] = -1;
			v[j] = -1;
		}
		for (int j = 0; j < n; j++)
		{
			v[a[j]] = max(v[a[j]], j - cur[a[j]]);
			cur[a[j]] = j;
		}
		for (int j = 1; j <= n; j++)
		{
			if (v[j] != -1)
			{
				v[j] = max(v[j], n - cur[j]);
			}
			else
			{
				v[j] = 1e9;
			}
		}
		vector<int>ans;
		int in = 1;
		for (int j = n; j >=1; j--)
		{
			while (v[in] > j)
			{
				in++;
			}
			if (in > n)
			{
				ans.push_back(-1);
			}
			else
			{
				ans.push_back(in);
			}
		}
		for (int j = n - 1; j >= 0; j--)
		{
			cout << ans[j] << " ";
		}
		cout << "\n";
	}
}


#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<deque>
#include<map>
#include<unordered_map>
#include<string>
#include<stack>
#include<vector>
#include<set>
#include<iomanip>
#include <cmath>
#include <iterator>
#include <cstdint>
#include <list>
#include <memory>
#include <unordered_set>
#include <sstream>
#include <cassert>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>
#define ll long long
using namespace std;
#define int long long
int a[400000];
int cur[400000];
int v[400000];
void main()
{
#if defined _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	std::ios::sync_with_stdio(false);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	int n;
	for (int i = 0; i < t; i++)
	{
		cin >> n;
		for (int j = 0; j < n; j++)
		{
			cin >> a[j];
			cur[j+1] = -1;
			v[j+1] = -1;
		}
		for (int j = 0; j < n; j++)
		{
			v[a[j]] = max(v[a[j]], j - cur[a[j]]);
			cur[a[j]] = j;
		}
		for (int j = 1; j <= n; j++)
		{
			if (v[j] != -1)
			{
				v[j] = max(v[j], n - cur[j]);
			}
			else
			{
				v[j] = 1e9;
			}
		}
		vector<int>ans;
		int in = 1;
		for (int j = n; j >=1; j--)
		{
			while (v[in] > j)
			{
				in++;
			}
			if (in > n)
			{
				ans.push_back(-1);
			}
			else
			{
				ans.push_back(in);
			}
		}
		for (int j = n - 1; j >= 0; j--)
		{
			cout << ans[j] << " ";
		}
		cout << "\n";
	}
}


#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
using namespace std;
int maxgap(vector<int>* v, int n) {
	v->push_back(n);
	vector<int>::iterator i;
	int gap = 0;
	for (i = v->begin(); i != v->end(); i++) {
		if (i == v->begin()) gap = *i;
		else {
			int testgap = *i;
			i--;
			testgap -= *i;
			i++;
			testgap--;
			if (testgap > gap) gap = testgap;
		}
	}
	i = v->end();
	i--;
	return gap;
}
int main() {
	int testcase;
	cin >> testcase;
	for (int testnum = 0; testnum < testcase; testnum++) {
		int n;
		cin >> n;
		map<int, vector<int>*> nums;//List of number indices
		for (int j = 0; j < n; j++) {
			int m;
			cin >> m;
			map<int, vector<int>*>::iterator it = nums.find(m);
			if (it == nums.end()) {
				vector<int>* v = new vector<int>;
				v->push_back(j);
				nums.emplace(m, v);
			}
			else {
				it->second->push_back(j);
			}
		}
		map<int, int> gaps; //Map of gap size to minimal number
		map<int, vector<int>*>::iterator it;
		for (it = nums.begin(); it != nums.end(); it++) {
			int max = maxgap(it->second, n);
			cerr << it->first << " " << max << endl;
			if (gaps.find(max) == gaps.end()) {
				gaps.emplace(max, it->first);
			}
			else {
				int test = gaps.find(max)->second;
				if (test > it->first) {
					gaps.erase(gaps.find(max));
					gaps.emplace(max, it->first);
				}
			}
		}
		vector<int> output;
		for (int i = 0; i < n; i++) {
			output.push_back(999999999);
		}
		for (int i = 0; i < n; i++) {
			map<int, int>::iterator it = gaps.find(i);
			if (it != gaps.end()) {
				if (output[i] > it->second) {
					for (int j = i; j < n; j++) {
						output[i] = it->second;
					}
				}
			}
		}
		for (int i = 1; i < n; i++) {
			if (output[i] > output[i - 1]) output[i] = output[i - 1];
		}
		for (int i = 0; i < n - 1; i++) {
			if (output[i] == 999999999) cout << -1;
			else cout << output[i];
			cout << ' ';
		}
		if (output[n-1] == 999999999) cout << -1;
		else cout << output[n-1];
		cout << endl;

	}

}


#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
using namespace std;
int maxgap(vector<int>* v, int n) {
	v->push_back(n);
	vector<int>::iterator i;
	int gap = 0;
	for (i = v->begin(); i != v->end(); i++) {
		if (i == v->begin()) gap = *i;
		else {
			int testgap = *i;
			i--;
			testgap -= *i;
			i++;
			testgap--;
			if (testgap > gap) gap = testgap;
		}
	}
	i = v->end();
	i--;
	return gap;
}
int main() {
	int testcase;
	cin >> testcase;
	for (int testnum = 0; testnum < testcase; testnum++) {
		int n;
		cin >> n;
		map<int, vector<int>*> nums;//List of number indices
		for (int j = 0; j < n; j++) {
			int m;
			cin >> m;
			map<int, vector<int>*>::iterator it = nums.find(m);
			if (it == nums.end()) {
				vector<int>* v = new vector<int>;
				v->push_back(j);
				nums.emplace(m, v);
			}
			else {
				it->second->push_back(j);
			}
		}
		map<int, int> gaps; //Map of gap size to minimal number
		map<int, vector<int>*>::iterator it;
		for (it = nums.begin(); it != nums.end(); it++) {
			int max = maxgap(it->second, n);
			if (gaps.find(max) == gaps.end()) {
				gaps.emplace(max, it->first);
			}
			else {
				int test = gaps.find(max)->second;
				if (test > it->first) {
					gaps.erase(gaps.find(max));
					gaps.emplace(max, it->first);
				}
			}
		}
		vector<int> output;
		for (int i = 0; i < n; i++) {
			output.push_back(999999999);
		}
		for (int i = 0; i < n; i++) {
			map<int, int>::iterator it = gaps.find(i);
			if (it != gaps.end()) {
				if (output[i] > it->second) {
					output[i] = it->second;
				}
			}
		}
		for (int i = 1; i < n; i++) {
			if (output[i] > output[i - 1]) output[i] = output[i - 1];
		}
		for (int i = 0; i < n - 1; i++) {
			if (output[i] == 999999999) cout << -1;
			else cout << output[i];
			cout << ' ';
		}
		if (output[n-1] == 999999999) cout << -1;
		else cout << output[n-1];
		cout << endl;

	}

}


#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include "stdio.h"
using namespace std;
const int N = 3 * 100010;
int a[N], res[N];
vector<int> v[N];
void solve_case(int tc)
{
	int n, T, k, mn = 10000000, ind = -1;
	cin >> n;
	vector<int> r;

	for (int i = 1; i <= n; ++i) {
		v[i].clear();
		v[i].push_back(0);
	}

	for (int i = 1; i <= n; ++i) {
		cin >> k;
		v[k].push_back(i);
	}

	for (int i = 1; i <= n; ++i) {
		v[i].push_back(n + 1);
		sort(v[i].begin(), v[i].end());
		a[i] = 0;
		res[i] = -1;
		for (int j = 1; j < v[i].size(); ++j)
			a[i] = max(a[i], v[i][j] - v[i][j - 1]);
	}

	int cur = n+1;
	for (int i = 1; i <= n; ++i) {
		if (a[i] == n + 1)
			continue;

		if (a[i] < cur) {
			for (int j = a[i]; j < cur; j++)
				r.push_back(i);
			cur = a[i];
		}
	}

	for (int i = 1; i < cur; ++i)
		cout << -1 << " ";

	for (int i = 0; i < r.size(); ++i)
		cout << r[r.size() - i - 1] << " ";

	cout << endl;
}

void prepare()
{
}

int main()
{

#ifdef __OLIMP__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int T = 1;
	scanf("%d", &T);
	prepare();
	for (int tc = 1; tc <= T; tc++)
		solve_case(tc);

	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include "stdio.h"
using namespace std;
const int N = 100010;
int a[N], res[N];
vector<int> v[N];
void solve_case(int tc)
{
	int n, T, k, mn = 10000000, ind = -1;
	cin >> n;
	vector<int> r;

	for (int i = 1; i <= n; ++i) {
		v[i].clear();
		v[i].push_back(0);
	}

	for (int i = 1; i <= n; ++i) {
		cin >> k;
		v[k].push_back(i);
	}

	for (int i = 1; i <= n; ++i) {
		v[i].push_back(n + 1);
		sort(v[i].begin(), v[i].end());
		a[i] = 0;
		res[i] = -1;
		for (int j = 1; j < v[i].size(); ++j)
			a[i] = max(a[i], v[i][j] - v[i][j - 1]);
	}

	int cur = n+1;
	for (int i = 1; i <= n; ++i) {
		if (a[i] == n + 1)
			continue;

		if (a[i] < cur) {
			for (int j = a[i]; j < cur; j++)
				r.push_back(i);
			cur = a[i];
		}
	}

	for (int i = 1; i < cur; ++i)
		cout << -1 << " ";

	for (int i = 0; i < r.size(); ++i)
		cout << r[r.size() - i - 1] << " ";

	cout << endl;
}

void prepare()
{
}

int main()
{

#ifdef __OLIMP__
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int T = 1;
	scanf("%d", &T);
	prepare();
	for (int tc = 1; tc <= T; tc++)
		solve_case(tc);

	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#define N 300000
using namespace std;
typedef int ll;
int a[N + 1], max_dist[N + 1], min_dist[N + 1][2];
int last_idx[N + 1];
bool visit[N + 1];
int main()
{
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;

		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			if (last_idx[a[i]] != 0 && i - last_idx[a[i]] > max_dist[a[i]]) max_dist[a[i]] = i - last_idx[a[i]];
			else if (last_idx[a[i]] == 0) max_dist[a[i]] = i;
			last_idx[a[i]] = i;
		}

		for (int i = 1; i <= n; i++) {
			if (n - last_idx[a[i]] + 1 > max_dist[a[i]]) max_dist[a[i]] = n - last_idx[a[i]] + 1;
		}

		for (int i = n; i >= 1; i--) {
			if (visit[a[i]] == 0) {
				if (min_dist[max_dist[a[i]]][0] == 0) {
					min_dist[max_dist[a[i]]][0] = 1;
					min_dist[max_dist[a[i]]][1] = a[i];
				}
				else {
					if (min_dist[max_dist[a[i]]][1] > a[i]) {
						min_dist[max_dist[a[i]]][1] = a[i];
					}
				}
				visit[a[i]] = 1;
			}

		}
		int pre = -1;
		for (int i = 1; i <= n; i++) {
			if (min_dist[i][0] == 0) {
				if (pre == -1) printf("-1 ");
				else printf("%d ", pre);
			}
			else {
				if (pre == -1 || pre > min_dist[i][1]) pre = min_dist[i][1];
				printf("%d ", pre);
			}
		}
		printf("\n");
		for (int i = 1; i <= n; i++) max_dist[a[i]] = 0, min_dist[a[i]][0] = 0, min_dist[a[i]][1] = 0, a[i] = 0, visit[i] = 0, last_idx[i] = 0;
	}
	return 0;
}


#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<queue>
#define N 300000
using namespace std;
typedef int ll;
int a[N + 1], max_dist[N + 1], min_dist[N + 1][2];
int last_idx[N + 1];
bool visit[N + 1];
int main()
{
	int t;
	cin >> t;
	while (t--) {
		int n;
		cin >> n;

		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			if (last_idx[a[i]] == 0) max_dist[a[i]] = i;
			else if (i - last_idx[a[i]] > max_dist[a[i]]) max_dist[a[i]] = i - last_idx[a[i]];
			last_idx[a[i]] = i;
		}

		for (int i = 1; i <= n; i++) {
			if (n - last_idx[a[i]] + 1 > max_dist[a[i]]) max_dist[a[i]] = n - last_idx[a[i]] + 1;
		}

		for (int i = 1; i <= n; i++) {
			if (visit[a[i]] == 0) {
				if (min_dist[max_dist[a[i]]][0] == 0) {
					min_dist[max_dist[a[i]]][0] = 1;
					min_dist[max_dist[a[i]]][1] = a[i];
				}
				else {
					if (min_dist[max_dist[a[i]]][1] > a[i]) {
						min_dist[max_dist[a[i]]][1] = a[i];
					}
				}
				visit[a[i]] = 1;
			}

		}
		int pre = -1;
		for (int i = 1; i <= n; i++) {
			if (min_dist[i][0] == 0) printf("%d ", pre);
			else {
				if (pre == -1 || pre > min_dist[i][1]) pre = min_dist[i][1];
				printf("%d ", pre);
			}
		}
		printf("\n");
		for (int i = 1; i <= n; i++) max_dist[i] = 0, min_dist[i][0] = 0, min_dist[i][1] = 0, a[i] = 0, visit[i] = 0, last_idx[i] = 0;
	}
	return 0;
}


#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <functional>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstring>
#include <map>
#include <set>
#include <deque>
#include <complex>
#include <limits.h>
#define all(v) (v).begin(),(v).end()
#define sz(v) ((v).size())
#define F(i,s,n) for(int i=s;i<=n;i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using pdd = pair<double, double>;
using pil = pair<int, ll>;

int n;
int a[300001];
vi c[300001];
int ans[300001];

int main() {
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int tc;
	cin >> tc;
	while (tc--) {

		cin >> n;
		bool dif = false;
		F(i, 1, n) {
			cin >> a[i];
			c[a[i]].push_back(i);
			ans[i] = 10000000;
		}
		F(i, 1, n)
			if (a[i] != a[1])
				dif = true;
		F(i,1,n)
			if (c[i].size()>1) {
				int maxdist = 0;
				int f = c[i][0];
				maxdist = max(maxdist, c[i][0]);
				F(j, 1, c[i].size() - 1) {
					maxdist = max(maxdist, c[i][j] - f);
					f = c[i][j];
				}
				maxdist = max(maxdist, n+1 - c[i][c[i].size() - 1]);
				if (maxdist == 1)
					continue;
				ans[maxdist] = min(ans[maxdist], i);
			}
		if (!dif)
			ans[1] = a[1];
		int bf = 10000000;
		F(i, 1, n) {
			ans[i] = min(ans[i], bf);
			if (i * 2 > n)
				ans[i] = min({ ans[i],a[i],a[n + 1 - i] });
			if (ans[i] == 10000000)
				cout << -1;
			else
				cout << ans[i];
			cout << " ";
			bf = ans[i];
		}
		cout << "\n";
		F(i, 1, n)
			c[i].clear();
	}
}


#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <functional>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstring>
#include <map>
#include <set>
#include <deque>
#include <complex>
#include <limits.h>
#define all(v) (v).begin(),(v).end()
#define sz(v) ((v).size())
#define F(i,s,n) for(int i=s;i<=n;i++)
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using pdd = pair<double, double>;
using pil = pair<int, ll>;

int n;
int a[300001];
vi c[300001];
int ans[300001];

int main() {
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif*/
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

	int tc;
	cin >> tc;
	while (tc--) {

		cin >> n;
		bool dif = false;
		F(i, 1, n) {
			cin >> a[i];
			c[a[i]].push_back(i);
			ans[i] = 10000000;
		}
		F(i, 1, n)
			if (a[i] != a[1])
				dif = true;
		F(i,1,n)
			if (c[i].size()>1) {
				int maxdist = 0;
				int f = c[i][0];
				F(j, 1, c[i].size() - 1) {
					maxdist = max(maxdist, c[i][j] - f);
					f = c[i][j];
				}
				maxdist = max(maxdist, n+1 - c[i][c[i].size() - 1]);
				if (maxdist == 1)
					continue;
				ans[maxdist] = min(ans[maxdist], i);
			}
		if (!dif)
			ans[1] = a[1];
		int bf = 10000000;
		F(i, 1, n) {
			ans[i] = min(ans[i], bf);
			if (i * 2 > n) {
				if (i * 2 - 1 == n)
					ans[i] = min(ans[i], a[i]);
				else
					ans[i] = min({ ans[i],a[i],a[n + 1 - i] });
			}
			if (ans[i] == 10000000)
				cout << -1;
			else
				cout << ans[i];
			cout << " ";
			bf = ans[i];
		}
		cout << "\n";
		F(i, 1, n)
			c[i].clear();
	}
}


#include<stdio.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
int a[300013];
int b[200013];
int nu[300013];
int ma[300013];
int ch[300013];
vector<pair<int, int>> va;
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	else return a.first < b.first;
}
int main() {
	int t;
	scanf("%d", &t);

	while (t--) {

		int n, k;
		scanf("%d", &n);
		for (int i = 0; i <= n; i++) {
			b[i] = -1;
			nu[i] = -1;
			ma[i] = 0;
			ch[i] = 0;
		}
		int check = 0;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			if (a[i] == a[0]) check++;
			if (ma[a[i]] != 0) {
				nu[a[i]] = max(nu[a[i]], i - ma[a[i]]);
			}
			ch[a[i]]++;
			ma[a[i]] = i;

		}
		for (int i = 1; i <= n; i++) {
			if (ch[i]>=2) {
				nu[i] = max((n + 1) - ma[i], nu[i]);
				va.push_back(make_pair(nu[i], i));
			}
		}
		int min1 = 999999;
		int j = 0;
		sort(va.begin(), va.end(), cmp);
		if (n == 300) {
			for (int i = 0; i < va.size(); i++) {
				printf("%d %d\n", va[i].first, va[i].second);
			}
		}
		if (!va.empty()) {
			for (int i = 1; i < va[0].first; i++) {
				b[i] = -1;
			}
			for (int i = va[0].first; i <= n / 2; i++) {
				while (va.size()!=j) {
					if (va[j].first > i) break;
					min1 = min(va[j].second, min1);
					j++;

				}
				b[i] = min1;
			}
		}
		else {
			for (int i = 1; i <= n / 2; i++) b[i] = -1;
		}
		int x;
		int y;
		if (n % 2 == 0) {
			x = n / 2;
			y = n / 2 + 1;
		}
		else {
			x = n / 2 + 1;
			y = x;
		}

		for (int i = n / 2 + 1; i <= n; i++) {
			if (min1 > a[x]) min1 = a[x];
			if (min1 > a[y]) min1 = a[y];
			b[i] = min1;
			y++;
			x--;
		}
		for (int i = 1; i <= n; i++) {
			printf("%d ", b[i]);
		}
		printf("\n");
		va.clear();
	}
}


#include<stdio.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
int a[300013];
int b[200013];
int nu[300013];
int ma[300013];
int ch[300013];
vector<pair<int, int>> va;
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	else return a.first < b.first;
}
int main() {
	int t;
	scanf("%d", &t);

	while (t--) {

		int n, k;
		scanf("%d", &n);
		for (int i = 0; i <= n; i++) {
			b[i] = -1;
			nu[i] = -1;
			ma[i] = 0;
			ch[i] = 0;
		}
		int check = 0;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			nu[a[i]] = max(nu[a[i]], i - ma[a[i]]);
			ch[a[i]]++;
			ma[a[i]] = i;

		}
		for (int i = 1; i <= n; i++) {
			if (ch[i]>=1) {
				nu[i] = max((n + 1) - ma[i], nu[i]);
				va.push_back(make_pair(nu[i], i));
			}
		}
		int min1 = 999999;
		int j = 0;
		sort(va.begin(), va.end(), cmp);

		if (!va.empty()) {
			for (int i = 0; i < va.size(); i++) {
				printf("%d %d\n", va[i].first, va[i].second);
			}
			for (int i = 1; i < va[0].first; i++) {
				b[i] = -1;
			}
			for (int i = va[0].first; i <= n; i++) {
				while (va.size()!=j) {
					if (va[j].first > i) break;
					min1 = min(va[j].second, min1);
					j++;

				}
				b[i] = min1;
			}
		}
		else {
			for (int i = 1; i <= n / 2; i++) b[i] = -1;
		}
		int x;
		int y;
		if (n % 2 == 0) {
			x = n / 2;
			y = n / 2 + 1;
		}
		else {
			x = n / 2 + 1;
			y = x;
		}
		for (int i = 1; i <= n; i++) {
			printf("%d ", b[i]);
		}
		printf("\n");
		va.clear();
	}
}


#include<stdio.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
int a[300013];
int b[200013];
int nu[300013];
int ma[300013];
vector<pair<int, int>> va;
bool cmp(const pair<int, int>  &a, const pair<int, int> & b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	else return a.first < b.first;
}
int main() {
	int t;
	scanf("%d", &t);

	while (t--) {

		int n, k;
		scanf("%d", &n);
		for (int i = 0; i <= n; i++) {
			b[i] = -1;
			nu[i] = -1;
			ma[i] = 0;
		}
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			if (ma[a[i]] != 0) {
				nu[a[i]] = max(nu[a[i]], i - ma[a[i]]);
			}
			ma[a[i]] = i;

		}
		for (int i = 1; i <= n; i++) {
			if (nu[i] != -1) {
				va.push_back(make_pair(nu[i], i));
			}
		}

		int min1 = 999999;
		int j = 0;
		if (!va.empty()) {
			for (int i = 1; i < va[0].first; i++) {
				b[i] = -1;
			}
			for (int i = va[0].first; i <= n / 2; i++) {
				for (j; j < va.size();) {
					if (va[j].first > i) break;
					else {
						min1 = min(va[j].second, min1);
						j++;
					}
				}
				b[i] = min1;
			}
		}
		else {
			for (int i = 1; i <= n / 2; i++) b[i] = -1;
		}
		int min = 300014;
		int x;
		int y;
		if (n % 2 == 0) {
			x = n / 2;
			y = n / 2 + 1;
		}
		else {
			x = n / 2 + 1;
			y = x;
		}

		for (int i = n / 2 + 1; i <= n; i++) {
			if (min > a[x]) min = a[x];
			if (min > a[y]) min = a[y];
			b[i] = min;
			y++;
			x--;
		}
		for (int i = 1; i <= n; i++) {
			printf("%d ", b[i]);
		}
		printf("\n");
		va.clear();
	}
}


#include<stdio.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
int a[300013];
int b[200013];
int nu[300013];
int ma[300013];
vector<pair<int, int>> va;
bool cmp(const pair<int, int>  &a, const pair<int, int> & b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	else return a.first < b.first;
}
int main() {
	int t;
	scanf("%d", &t);

	while (t--) {

		int n, k;
		scanf("%d", &n);
		for (int i = 0; i <= n; i++) {
			b[i] = -1;
			nu[i] = -1;
			ma[i] = 0;
		}
		int check = 0;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			if (a[i] == a[0]) check++;
			if (ma[a[i]] != 0) {
				nu[a[i]] = max(nu[a[i]], i - ma[a[i]]);
			}
			ma[a[i]] = i;

		}
		for (int i = 1; i <= n; i++) {
			if (nu[i] != -1) {
				va.push_back(make_pair(nu[i], i));
			}
		}

		int min1 = 999999;
		int j = 0;
		if (!va.empty()) {
			for (int i = 1; i < va[0].first; i++) {
				b[i] = -1;
			}
			for (int i = va[0].first; i <= n / 2; i++) {
				for (j; j < va.size();) {
					if (va[j].first > i) break;
					else {
						min1 = min(va[j].second, min1);
						j++;
					}
				}
				b[i] = min1;
			}
		}
		else {
			for (int i = 1; i <= n / 2; i++) b[i] = -1;
		}
		int min = 300014;
		int x;
		int y;
		if (n % 2 == 0) {
			x = n / 2;
			y = n / 2 + 1;
		}
		else {
			x = n / 2 + 1;
			y = x;
		}

		for (int i = n / 2 + 1; i <= n; i++) {
			if (min > a[x]) min = a[x];
			if (min > a[y]) min = a[y];
			b[i] = min;
			y++;
			x--;
		}
		if (check != n) b[1] = -1;
		for (int i = 1; i <= n; i++) {
			printf("%d ", b[i]);
		}
		printf("\n");
		va.clear();
	}
}


#include<stdio.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
int a[300013];
int b[200013];
int nu[300013];
int ma[300013];
vector<pair<int, int>> va;
bool cmp(const pair<int, int>  &a, const pair<int, int> & b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	else return a.first < b.first;
}
int main() {
	int t;
	scanf("%d", &t);

	while (t--) {

		int n, k;
		scanf("%d", &n);
		for (int i = 0; i <= n; i++) {
			b[i] = -1;
			nu[i] = -1;
			ma[i] = 0;
		}
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			if (ma[a[i]] != 0) {
				nu[a[i]] = max(nu[a[i]], i - ma[a[i]]);
			}
			ma[a[i]] = i;

		}
		for (int i = 1; i <= n; i++) {
			if (nu[i] != -1) {
				va.push_back(make_pair(nu[i], i));
			}
		}

		int min1 = 999999;
		int j = 0;
		if (!va.empty()) {
			for (int i = 0; i < va.size(); i++) {
				printf("%d %d %d\n", i, va[i].first, va[i].second);
			}
			for (int i = 1; i < va[0].first; i++) {
				b[i] = -1;
			}
			for (int i = va[0].first; i <= n / 2; i++) {
				for (j; j < va.size();) {
					if (va[j].first > i) break;
					else {
						min1 = min(va[j].second, min1);
						j++;
					}
				}
				b[i] = min1;
			}
		}
		else {
			for (int i = 1; i <= n / 2; i++) b[i] = -1;
		}
		int min = 300014;
		int x;
		int y;
		if (n % 2 == 0) {
			x = n / 2;
			y = n / 2 + 1;
		}
		else {
			x = n / 2 + 1;
			y = x;
		}

		for (int i = n / 2 + 1; i <= n; i++) {
			if (min > a[x]) min = a[x];
			if (min > a[y]) min = a[y];
			b[i] = min;
			y++;
			x--;
		}
		for (int i = 1; i <= n; i++) {
			printf("%d ", b[i]);
		}
		printf("\n");
		va.clear();
	}
}


#include<stdio.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
int a[300013];
int b[200013];
int nu[300013];
int ma[300013];
vector<pair<int, int>> va;
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	else return a.first < b.first;
}
int main() {
	int t;
	scanf("%d", &t);

	while (t--) {

		int n, k;
		scanf("%d", &n);
		for (int i = 0; i <= n; i++) {
			b[i] = -1;
			nu[i] = -1;
			ma[i] = 0;
		}
		int check = 0;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			if (a[i] == a[0]) check++;
			if (ma[a[i]] != 0) {
				nu[a[i]] = max(nu[a[i]], i - ma[a[i]]);
			}
			ma[a[i]] = i;

		}
		for (int i = 1; i <= n; i++) {
			if (nu[i] != -1) {
				nu[i] = max((n + 1) - ma[i], nu[i]);
				va.push_back(make_pair(nu[i], i));
			}
		}
		int min1 = 999999;
		int j = 0;
		sort(va.begin(), va.end(), cmp);
		if (n == 300) {
			for (int i = 0; i < va.size(); i++) {
				printf("%d %d\n", va[i].first, va[i].second);
			}
		}
		if (!va.empty()) {
			for (int i = 1; i < va[0].first; i++) {
				b[i] = -1;
			}
			for (int i = va[0].first; i <= n / 2; i++) {
				while (!va.size()==j) {
					if (va[j].first >= i) break;
					min1 = min(va[j].second, min1);
					j++;

				}
				b[i] = min1;
			}
		}
		else {
			for (int i = 1; i <= n / 2; i++) b[i] = -1;
		}
		int x;
		int y;
		if (n % 2 == 0) {
			x = n / 2;
			y = n / 2 + 1;
		}
		else {
			x = n / 2 + 1;
			y = x;
		}

		for (int i = n / 2 + 1; i <= n; i++) {
			if (min1 > a[x]) min1 = a[x];
			if (min1 > a[y]) min1 = a[y];
			b[i] = min1;
			y++;
			x--;
		}
		for (int i = 1; i <= n; i++) {
			printf("%d ", b[i]);
		}
		printf("\n");
		va.clear();
	}
}


#include<stdio.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
int a[300013];
int b[200013];
int nu[300013];
int ma[300013];
vector<pair<int, int>> va;
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	else return a.first < b.first;
}
int main() {
	int t;
	scanf("%d", &t);

	while (t--) {

		int n, k;
		scanf("%d", &n);
		for (int i = 0; i <= n; i++) {
			b[i] = -1;
			nu[i] = -1;
			ma[i] = 0;
		}
		int check = 0;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			if (a[i] == a[0]) check++;
			if (ma[a[i]] != 0) {
				nu[a[i]] = max(nu[a[i]], i - ma[a[i]]);
			}
			ma[a[i]] = i;

		}
		for (int i = 1; i <= n; i++) {
			if (nu[i] != -1) {
				nu[i] = max((n + 1) - ma[i], nu[i]);
				va.push_back(make_pair(nu[i], i));
			}
		}
		int min1 = 999999;
		int j = 0;
		sort(va.begin(), va.end(), cmp);
		if (n == 300) {
			for (int i = 0; i < va.size(); i++) {
				printf("%d %d\n", va[i].first, va[i].second);
			}
		}
		if (!va.empty()) {
			for (int i = 1; i < va[0].first; i++) {
				b[i] = -1;
			}
			for (int i = va[0].first; i <= n / 2; i++) {
				while (va.size()!=j) {
					if (va[j].first > i) break;
					min1 = min(va[j].second, min1);
					j++;

				}
				b[i] = min1;
			}
		}
		else {
			for (int i = 1; i <= n / 2; i++) b[i] = -1;
		}
		int x;
		int y;
		if (n % 2 == 0) {
			x = n / 2;
			y = n / 2 + 1;
		}
		else {
			x = n / 2 + 1;
			y = x;
		}

		for (int i = n / 2 + 1; i <= n; i++) {
			if (min1 > a[x]) min1 = a[x];
			if (min1 > a[y]) min1 = a[y];
			b[i] = min1;
			y++;
			x--;
		}
		for (int i = 1; i <= n; i++) {
			printf("%d ", b[i]);
		}
		printf("\n");
		va.clear();
	}
}


#include<stdio.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
int a[300013];
int b[200013];
int nu[300013];
int ma[300013];
vector<pair<int, int>> va;
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	else return a.first < b.first;
}
int main() {
	int t;
	scanf("%d", &t);

	while (t--) {

		int n, k;
		scanf("%d", &n);
		for (int i = 0; i <= n; i++) {
			b[i] = -1;
			nu[i] = -1;
			ma[i] = 0;
		}
		int check = 0;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			if (a[i] == a[0]) check++;
			if (ma[a[i]] != 0) {
				nu[a[i]] = max(nu[a[i]], i - ma[a[i]]);
			}
			ma[a[i]] = i;

		}
		for (int i = 1; i <= n; i++) {
			if (nu[i] != -1) {
				nu[i] = max((n + 1) - ma[i], nu[i]);
				va.push_back(make_pair(nu[i], i));
			}
		}
		int min1 = 999999;
		int j = 0;
		sort(va.begin(), va.end(), cmp);
		if (n == 1000) {
			for (int i = 0; i < va.size(); i++) {
				printf("%d %d\n", va[i].first, va[i].second);
			}
		}
		if (!va.empty()) {
			for (int i = 1; i < va[0].first; i++) {
				b[i] = -1;
			}
			for (int i = va[0].first; i <= n / 2; i++) {
				while (!va.size()==j) {
					if (va[j].first > i) break;
					min1 = min(va[j].second, min1);
					j++;

				}
				b[i] = min1;
			}
		}
		else {
			for (int i = 1; i <= n / 2; i++) b[i] = -1;
		}
		int x;
		int y;
		if (n % 2 == 0) {
			x = n / 2;
			y = n / 2 + 1;
		}
		else {
			x = n / 2 + 1;
			y = x;
		}

		for (int i = n / 2 + 1; i <= n; i++) {
			if (min1 > a[x]) min1 = a[x];
			if (min1 > a[y]) min1 = a[y];
			b[i] = min1;
			y++;
			x--;
		}
		for (int i = 1; i <= n; i++) {
			printf("%d ", b[i]);
		}
		printf("\n");
		va.clear();
	}
}


#include<stdio.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
int a[300013];
int b[200013];
int nu[300013];
int ma[300013];
int ch[300013];
vector<pair<int, int>> va;
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	else return a.first < b.first;
}
int main() {
	int t;
	scanf("%d", &t);

	while (t--) {

		int n, k;
		scanf("%d", &n);
		for (int i = 0; i <= n; i++) {
			b[i] = -1;
			nu[i] = -1;
			ma[i] = 0;
			ch[i] = 0;
		}
		int check = 0;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			nu[a[i]] = max(nu[a[i]], i - ma[a[i]]);
			ch[a[i]]++;
			ma[a[i]] = i;

		}
		for (int i = 1; i <= n; i++) {
			if (ch[i]>=1) {
				nu[i] = max((n + 1) - ma[i], nu[i]);
				va.push_back(make_pair(nu[i], i));
			}
		}
		int min1 = 999999;
		int j = 0;
		sort(va.begin(), va.end(), cmp);

		if (!va.empty()) {
			for (int i = 1; i < va[0].first; i++) {
				b[i] = -1;
			}
			for (int i = va[0].first; i <= n; i++) {
				while (va.size()!=j) {
					if (va[j].first > i) break;
					min1 = min(va[j].second, min1);
					j++;

				}
				b[i] = min1;
			}
		}
		else {
			for (int i = 1; i <= n / 2; i++) b[i] = -1;
		}
		int x;
		int y;
		if (n % 2 == 0) {
			x = n / 2;
			y = n / 2 + 1;
		}
		else {
			x = n / 2 + 1;
			y = x;
		}
		for (int i = 1; i <= n; i++) {
			printf("%d ", b[i]);
		}
		printf("\n");
		va.clear();
	}
}


#include<stdio.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
int a[300013];
int b[200013];
int nu[300013];
int ma[300013];
int ch[300013];
vector<pair<int, int>> va;
bool cmp(const pair<int, int>& a, const pair<int, int>& b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	else return a.first < b.first;
}
int main() {
	int t;
	scanf("%d", &t);

	while (t--) {

		int n, k;
		scanf("%d", &n);
		for (int i = 0; i <= n; i++) {
			b[i] = -1;
			nu[i] = -1;
			ma[i] = 0;
			ch[i] = 0;
		}
		int check = 0;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			if (ma[a[i]] != 0) {
				nu[a[i]] = max(nu[a[i]], i - ma[a[i]]);
			}
			else {
				ma[a[i]] = i;
				nu[a[i]] = ma[i];
			}
			ch[a[i]]++;
			ma[a[i]] = i;

		}
		for (int i = 1; i <= n; i++) {
			if (ch[i]>=1) {
				nu[i] = max((n + 1) - ma[i], nu[i]);
				va.push_back(make_pair(nu[i], i));
			}
		}
		int min1 = 999999;
		int j = 0;
		sort(va.begin(), va.end(), cmp);
		if (!va.empty()) {
			for (int i = 1; i < va[0].first; i++) {
				b[i] = -1;
			}
			for (int i = va[0].first; i <= n / 2; i++) {
				while (va.size()!=j) {
					if (va[j].first > i) break;
					min1 = min(va[j].second, min1);
					j++;

				}
				b[i] = min1;
			}
		}
		else {
			for (int i = 1; i <= n / 2; i++) b[i] = -1;
		}
		int x;
		int y;
		if (n % 2 == 0) {
			x = n / 2;
			y = n / 2 + 1;
		}
		else {
			x = n / 2 + 1;
			y = x;
		}
		for (int i = 1; i <= n; i++) {
			printf("%d ", b[i]);
		}
		printf("\n");
		va.clear();
	}
}


#include<stdio.h>
#include<string.h>
#include<time.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<algorithm>
using namespace std;
int a[300013];
int b[200013];
int nu[300013];
int ma[300013];
vector<pair<int, int>> va;
bool cmp(const pair<int, int>  &a, const pair<int, int> & b) {
	if (a.first == b.first) {
		return a.second < b.second;
	}
	else return a.first < b.first;
}
int main() {
	int t;
	scanf("%d", &t);

	while (t--) {

		int n, k;
		scanf("%d", &n);
		for (int i = 0; i <= n; i++) {
			b[i] = -1;
			nu[i] = -1;
			ma[i] = 0;
		}
		int check = 0;
		for (int i = 1; i <= n; i++) {
			scanf("%d", &a[i]);
			if (a[i] == a[0]) check++;
			if (ma[a[i]] != 0) {
				nu[a[i]] = max(nu[a[i]], i - ma[a[i]]);
			}
			ma[a[i]] = i;

		}
		for (int i = 1; i <= n; i++) {
			if (nu[i] != -1) {
				va.push_back(make_pair(nu[i], i));
			}
		}

		int min1 = 999999;
		int j = 0;
		sort(va.begin(), va.end(), cmp);
		if (!va.empty()) {
			for (int i = 1; i < va[0].first; i++) {
				b[i] = -1;
			}
			for (int i = va[0].first; i <= n / 2; i++) {
				for (j; j < va.size();) {
					if (va[j].first > i) break;
					else {
						min1 = min(va[j].second, min1);
						j++;
					}
				}
				b[i] = min1;
			}
		}
		else {
			for (int i = 1; i <= n / 2; i++) b[i] = -1;
		}
		int min = 300014;
		int x;
		int y;
		if (n % 2 == 0) {
			x = n / 2;
			y = n / 2 + 1;
		}
		else {
			x = n / 2 + 1;
			y = x;
		}

		for (int i = n / 2 + 1; i <= n; i++) {
			if (min > a[x]) min = a[x];
			if (min > a[y]) min = a[y];
			b[i] = min;
			y++;
			x--;
		}
		if (check != n) b[1] = -1;
		for (int i = 1; i <= n; i++) {
			printf("%d ", b[i]);
		}
		printf("\n");
		va.clear();
	}
}


#include <stdio.h>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstring>
#include <cctype>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <functional>
#include <algorithm>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cassert>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const ld PI = acos((ld)-1);
const ll MOD = 1000000007;

void ioFromFile(string inputFileName = "input.txt",
	string outputFileName = "output.txt") {
	ifstream* fin = new ifstream(inputFileName);
	ofstream* fout = new ofstream(outputFileName);
	cin.rdbuf(fin->rdbuf());
	cout.rdbuf(fout->rdbuf());
}

int read() { int x; scanf("%d", &x); return x; }
void write(int x) { printf("%d ", x); }
//---------------------------------------------------

void solve(){
  int n = read();
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    a[i] = read();
  }
  // vector<int> a{
  //   //1, 2, 3, 4, 5
  //   //4, 4, 4, 4, 2
  //   1, 3, 1, 5, 3, 1
  // };
  // int n = a.size();

  map<int, int> lastSeenAt;
  map<int, int> minInterval;
  for(int i = 0; i < n; i++){
    int v = a[i];
    if(lastSeenAt.count(v)){
      minInterval[v] = max(
        minInterval[v],
        i - lastSeenAt[v]
      );
    }
    else{
      minInterval[v] = i + 1;
    }

    lastSeenAt[v] = i;
  }
  //for(auto i : lastSeenAt) cout << i.first << " " << i.second << endl;
  for(auto i : minInterval){
    minInterval[i.first] = max(
      i.second,
      n - lastSeenAt[i.first]
    );
  }

  //for(auto i : minInterval) cout << i.first << " " << i.second << endl; cout << endl;

  vector<int> res(n);
  for(int i = 0; i < n; i++){
    int k = n - i;
    while(minInterval.size() > 0 && minInterval.begin()->second > k){
      minInterval.erase(minInterval.begin()->first);
    }

    res[i] = minInterval.size() > 0 ? minInterval.begin()->first : -1;
  }
  reverse(res.begin(), res.end());

  for(int i : res){
    write(i);
  }
  cout << endl;
}

int main(){
	int t = read();
	while(t--){
    solve();
	}

	return 0;
}

/*

3 2 2 1 1 3 5 1 2 3 3 7 3 2 2

2 6 7 1 2 3 4 5 6 3 6 3 3 3

3 5 1 2 3 4 5 5 4 4 4 4 2 6 1 3 1 5 3 1

*/


#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<random>
#include <cstdio>
#include<cassert>
#include <fstream>
#include <sstream>
#include <vector>
#include <set>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <iomanip>
#include <cstring>
#include <locale>
#include <unordered_map>
#include<unordered_set>
#include<bitset>
#include<stack>
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define all(x) (x).begin(),(x).end()
#define forn(i, e, n) for(int i = e; i < int(n); i++)
//#define makeunique(x) sort(all(x)), (x).resize(unique(all(x)) - (x).begin())
#define ff first
#define ss second
using namespace std;
mt19937 rnd(time(NULL));
typedef long long  ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF64 = ll(1e18);
const int INF = int(1e9) + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 * 2 + 100;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(10);
	int t;
	cin >> t;
	forn(_, 0, t)
	{
		int n;
		cin >> n;
		vector<int> a(n);
		forn(i, 0, n)
			cin >> a[i];
		vector<int> ans(n + 1, -1);
		vector<vector<int>> pos(n + 1);
		forn(i, 0, n)
			pos[a[i]].push_back(i);
		for(int i = n; i > 0; i--)
		{
			if (sz(pos[i]) == 0) continue;
			int mx = 0;
			forn(j, 0, sz(pos[i]) - 1)
			{
				mx = max(mx, pos[i][j + 1] - pos[i][j]);
			}
			mx = max(mx, n - pos[i].back());
			mx = max(mx, pos[i][0] + 1);
			ans[mx] = i;
		}
		int now = INF;
		forn(i, 1, n + 1)
		{
			if (ans[i] == -1 && now != INF)
			{
				ans[i] = now;
				continue;
			}
			if (ans[i] == -1 && now == INF) continue;
			ans[i] = min(ans[i], now);
			now = min(now, ans[i]);
		}
		forn(i, 1, n + 1)
			cout << ans[i] << ' ';
		cout << '\n';
	}

	return 0;
}


	#include <iostream>
	#include <string>
	#include <cstring>
	#include <set>
	#include <vector>
	#include<map>
	#include <stack>
	#include <queue>
	#include <algorithm>
	#include <typeinfo>
	#include <iomanip>
	#include <cmath>

	#define INF 1000000000
	#define mod 1000000007

	using namespace std;
	typedef long long ll;
	typedef vector<int> vi;
	typedef vector<bool> vb;
	typedef vector<long long> vll;
	typedef vector<vector<int>> vvi;
	typedef pair<int, int> pii;
	typedef vector<pii> vpii;

	int n;
	int pre[300001];
	int far[300001];
	void solve() {
		cin >> n;
		memset(pre, -1, sizeof(pre));
		memset(far, 0, sizeof(far));
		for (int i = 0; i < n; ++i) {
			int a;
			cin >> a;
			far[a] = max(far[a], i-pre[a]);
			pre[a] = i;
		}
		for (int a = 1; a <= n; ++a) {
			far[a] = max(far[a], n - pre[a]);
		}
		vpii v;
		for (int i = 1; i <= n; ++i) {
			cout << "#" << far[i] << " " << i << "\n";
			v.push_back({ far[i],i });
		}
		sort(v.begin(), v.end());
		int idx = 1;
		int m = -1;
		for (auto aa: v) {
			int i = aa.first;
			int a = aa.second;
			if (i == n + 1) break;
			if (m!=-1&&m < a) continue;
			while (idx < i) {
				cout << m << " ";
				idx++;
			}
			cout << a << " ";
			m = (m==-1?a:min(m,a));
			idx++;
			if (idx == n+1)
				break;
		}
		while (idx <= n) {
			cout << m << " ";
			idx++;
		}
		cout << "\n";
	}

	int main() {
		cin.sync_with_stdio(false);
		cin.tie(0);
		cout.sync_with_stdio(false);
		cout.tie(0);
		int t;
		cin >> t;
		while (t--)
			solve();

		return 0;
	}


#include <iostream>
#include <string>
#include <cstring>
#include <set>
#include <vector>
#include<map>
#include <stack>
#include <queue>
#include <algorithm>
#include <typeinfo>
#include <iomanip>
#include <cmath>

#define INF 1000000000
#define mod 1000000007

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<long long> vll;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

int n;
int pre[300001];
int far[300001];
void solve() {
	cin >> n;
	memset(pre, -1, sizeof(pre));
	memset(far, 0, sizeof(far));
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		far[a] = max(far[a], i-pre[a]);
		pre[a] = i;
	}
	for (int a = 1; a <= n; ++a) {
		far[a] = max(far[a], n - pre[a]);
	}
	vpii v;
	for (int i = 1; i <= n; ++i) {
		cout << "#" << far[i] << " " << i << "\n";
		v.push_back({ far[i],i });
	}
	sort(v.begin(), v.end());
	int idx = 1;
	int m = -1;

	for (auto aa: v) {
		int i = aa.first;
		int a = aa.second;
		if (m!=-1&&m < a) continue;
		while (idx < i) {
			cout << m << " ";
			idx++;
		}
		cout << a << " ";
		m = (m==-1?a:min(m,a));
		idx++;
		if (idx == n+1)
			break;
	}
	while (idx <= n) {
		cout << m << " ";
		idx++;
	}
	cout << "\n";
}

int main() {
	cin.sync_with_stdio(false);
	cin.tie(0);
	cout.sync_with_stdio(false);
	cout.tie(0);
	int t;
	cin >> t;
	while (t--)
		solve();

	return 0;
}


	#include <iostream>
	#include <string>
	#include <cstring>
	#include <set>
	#include <vector>
	#include<map>
	#include <stack>
	#include <queue>
	#include <algorithm>
	#include <typeinfo>
	#include <iomanip>
	#include <cmath>

	#define INF 1000000000
	#define mod 1000000007

	using namespace std;
	typedef long long ll;
	typedef vector<int> vi;
	typedef vector<bool> vb;
	typedef vector<long long> vll;
	typedef vector<vector<int>> vvi;
	typedef pair<int, int> pii;
	typedef vector<pii> vpii;

	int n;
	int pre[300001];
	int far[300001];
	void solve() {
		cin >> n;
		memset(pre, -1, sizeof(pre));
		memset(far, 0, sizeof(far));
		for (int i = 0; i < n; ++i) {
			int a;
			cin >> a;
			far[a] = max(far[a], i-pre[a]);
			pre[a] = i;
		}
		for (int a = 1; a <= n; ++a) {
			far[a] = max(far[a], n - pre[a]);
		}
		vpii v;
		for (int i = 1; i <= n; ++i) {
			v.push_back({ far[i],i });
		}
		sort(v.begin(), v.end());
		int idx = 1;
		int m = -1;

		for (auto aa: v) {
			int i = aa.first;
			int a = aa.second;
			if (m!=-1&&m < a) continue;
			while (idx < i) {
				cout << m << " ";
				idx++;
			}
			cout << a << " ";
			m = (m==-1?a:min(m,a));
			idx++;
			if (idx == n+1)
				break;
		}
		while (idx <= n) {
			cout << m << " ";
			idx++;
		}
		cout << "\n";
	}

	int main() {
		cin.sync_with_stdio(false);
		cin.tie(0);
		cout.sync_with_stdio(false);
		cout.tie(0);
		int t;
		cin >> t;
		while (t--)
			solve();

		return 0;
	}


	#include <iostream>
	#include <string>
	#include <cstring>
	#include <set>
	#include <vector>
	#include<map>
	#include <stack>
	#include <queue>
	#include <algorithm>
	#include <typeinfo>
	#include <iomanip>
	#include <cmath>

	#define INF 1000000000
	#define mod 1000000007

	using namespace std;
	typedef long long ll;
	typedef vector<int> vi;
	typedef vector<bool> vb;
	typedef vector<long long> vll;
	typedef vector<vector<int>> vvi;
	typedef pair<int, int> pii;
	typedef vector<pii> vpii;

	int n;
	int pre[300001];
	int far[300001];
	void solve() {
		cin >> n;
		memset(pre, -1, sizeof(pre));
		memset(far, 0, sizeof(far));
		for (int i = 0; i < n; ++i) {
			int a;
			cin >> a;
			far[a] = max(far[a], i-pre[a]);
			pre[a] = i;
		}
		for (int a = 1; a <= n; ++a) {
			far[a] = max(far[a], n - pre[a]);
		}
		vpii v;
		for (int i = 1; i <= n; ++i) {

			v.push_back({ far[i],i });
		}
		sort(v.begin(), v.end());
		int idx = 1;
		int m = -1;
		for (auto aa: v) {
			int i = aa.first;
			int a = aa.second;
			if (i == n + 1) break;
			if (m!=-1&&m < a) continue;
			while (idx < i) {
				cout << m << " ";
				idx++;
			}
			cout << a << " ";
			m = (m==-1?a:min(m,a));
			idx++;
			if (idx == n+1)
				break;
		}
		while (idx <= n) {
			cout << m << " ";
			idx++;
		}
		cout << "\n";
	}

	int main() {
		cin.sync_with_stdio(false);
		cin.tie(0);
		cout.sync_with_stdio(false);
		cout.tie(0);
		int t;
		cin >> t;
		while (t--)
			solve();

		return 0;
	}


#include<iostream>
#include<algorithm>
using namespace std;
const int max_n = 3e5 + 100;
int n;
int a[max_n];
int b[max_n];
int c[max_n];
int res[max_n];

int main() {
	ios::sync_with_stdio(0);
	int t;cin >> t;
	while (t--) {
		cin >> n;
		fill(b, b + n + 10, 0);
		fill(c, c + n + 10, 0);
		fill(res, res + n + 10, max_n);
		for (int i = 1;i <= n;++i)cin >> a[i];
		for (int i = 1;i <= n;++i) {
			b[a[i]] = max(i - c[a[i]], b[a[i]]);
			c[a[i]] = i;
		}for (int i = 1;i <= n;++i)
			b[i] = max(b[i], n + 1 - c[i]);
		for (int i=1;i<=n;++i)
			res[b[i]] = min(res[b[i]], i);
		for (int i = 2;i <= n;++i)
			res[i] = min(res[i - 1], res[i]);
		for (int i = 1;i <= n;++i) {
			if (res[i] == max_n)cout << -1 << " ";
			else cout << res[i] << " ";
		}cout << endl;
	}
}


//белый снег
//белый porshe
//белый trash
//в бонге воск
#include <iostream>
#include <locale>
#include <string>
#include <iomanip>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <vector>
#include <stdlib.h>
#include <clocale>
#include <algorithm>
#include <iterator>
#include <list>
#include <set>
#include <cstddef>
#include <cstdio>
#include <stdio.h>
#include <map>
#include <cmath>
#include <functional>
#include <stack>
#include <type_traits>
#include <queue>
#include <memory>
#include <memory.h>
#include <time.h>
#include <ctime>
#pragma warning(disable:4996)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
using namespace std;
#define Kirja_ES ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define pb push_back
#define pf push_front
#define irt insert
#define ll long long
#define ull unsigned long long
#define str string
#define vi vector<int>
#define vll vector<ll>
#define si set<int>
#define sll set<ll>
#define msi multiset<int>
#define msll multiset<ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define left false
#define right true
void solve()
{
	int n;
	cin >> n;
	map<int, si> in;
	int k = n, numb = 1e9;
	si in1;
	vi ansk(n+1);
	for (int i = 0; i < n; ++i)
	{
		int h;
		cin >> h;
		in[h].irt(i);
		in1.irt(h);
	}
	for (auto& it : in1)
	{
		in[it].irt(-1);
		in[it].irt(n);
		int pred = 0;
		int razn = 0;
		for (auto& it1 : in[it])
		{
			if (it1 != -1)
			{
				razn = max(razn, it1 - pred);
			}
			pred = it1;
		}
		if (ansk[razn] == 0)
			ansk[razn] = it;
		else
			ansk[razn] = min(ansk[razn], it);
	}
	for (int i = 1; i <= n; ++i)
	{
		if (ansk[i - 1] != 0)
		{
			if (ansk[i] == 0)
				ansk[i] = ansk[i - 1];
			else
				ansk[i] = min(ansk[i], ansk[i - 1]);
		}
	}
	for (int i = 1; i <= n; ++i)
	{
		if (ansk[i] == 0)
			cout << -1 << " ";
		else
			cout << ansk[i] << " ";
	}
	cout << "\n";
	return;
}
signed main()
{
	Kirja_ES;
	int t;
	cin >> t;
	while (t--)
		solve();
}