#include <bits/stdc++.h>
#define _itr ::iterator
#define forn(i, x, y) for (ll i = x; i < y; ++i)
#define ford(i, x, y) for (ll i = x; i > y; --i)
#define forne(i, x, y) for (ll i = x; i <= y; ++i)
#define forde(i, x, y) for (ll i = x; i >= y; --i)
#define rd(x) cin >> x; cin.ignore();
#define rdstr(x) getline(cin, x);
#define rdarr(x, y) for (ll i = 0; i < y; ++i) cin >> x[i];
#define rdmtr(x, y, z) for (ll i = 0; i < y; ++i) for (ll j = 0; j < z; ++j) cin >> x[i][j];
#define pb push_back

#define X first
#define Y second

using namespace std;
typedef long long ll;
typedef long double ld;

const ll MaxN = 1e5 + 7;
const ll MaxM = 1e2 + 7;
const ll MDL = 1e9 + 7;
const ll INF = 1e18 + 7;

typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef ll arr[MaxN];

ll REPIT = 1;

const bool MQ = true;

ll n, m;
arr so;
map<ll, vector<ll> > mp;
priority_queue<pi> res;
arr pos;

void Solve()
{
    cin >> n; rdarr(so, n); mp.clear();
    forn(i, 0, n) mp[so[i]].push_back(i);
    for (auto v : mp)
    {
        ll u = v.X; vi p = v.Y;
        ll r = min(max(p.front() + 1, n - p.front()), max(p.back() + 1, n - p.back()));
        for (ll i = 1; i < (ll)p.size(); ++i) r = min(p[i] - p[i - 1] + 1, r);
        res.push({-u, -(r - 1)});
//        cout << u << ' ' << r << '\n';
    }
    ll mx = n - 1;
    fill(pos, pos + n, -1);
    while (!res.empty())
    {
        pi u = res.top(); res.pop();
        ll st = -u.Y; if (st > mx) continue;
        forne(i, st, mx) pos[i] = -u.X;
        mx = st - 1;
    }
    forn(i, 0, n) cout << pos[i] << ' '; cout << '\n';
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef OFFLINE
    freopen("input.inp", "r", stdin);
    #endif
    if (MQ == true)
    {
        rd(REPIT);
    }
    while (REPIT--) Solve();
    cout.flush();
    #ifdef OFFLINE
    fclose(stdin);
    #endif
}


#include <bits/stdc++.h>
#define _itr ::iterator
#define forn(i, x, y) for (ll i = x; i < y; ++i)
#define ford(i, x, y) for (ll i = x; i > y; --i)
#define forne(i, x, y) for (ll i = x; i <= y; ++i)
#define forde(i, x, y) for (ll i = x; i >= y; --i)
#define rd(x) cin >> x; cin.ignore();
#define rdstr(x) getline(cin, x);
#define rdarr(x, y) for (ll i = 0; i < y; ++i) cin >> x[i];
#define rdmtr(x, y, z) for (ll i = 0; i < y; ++i) for (ll j = 0; j < z; ++j) cin >> x[i][j];
#define pb push_back

#define X first
#define Y second

using namespace std;
typedef long long ll;
typedef long double ld;

const ll MaxN = 3e5 + 7;
const ll MaxM = 1e2 + 7;
const ll MDL = 1e9 + 7;
const ll INF = 1e18 + 7;

typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef ll arr[MaxN];

ll REPIT = 1;

const bool MQ = true;

ll n, m;
arr so;
map<ll, vector<ll> > mp;
priority_queue<pi> res;
arr pos;

void Solve()
{
    cin >> n; rdarr(so, n); mp.clear();
    forn(i, 0, n) mp[so[i]].push_back(i);
    for (auto v : mp)
    {
        ll u = v.X; vi p = v.Y;
        ll r = max(p.front() + 1, n - p.back());
        for (ll i = 1; i < (ll)p.size(); ++i) r = max(p[i] - p[i - 1], r);
        res.push({-u, -(r - 1)});
//        cout << u << ' ' << r << '\n';
    }
    ll mx = n - 1;
    fill(pos, pos + n, -1);
    while (!res.empty())
    {
        pi u = res.top(); res.pop();
        ll st = -u.Y; if (st > mx) continue;
        forne(i, st, mx) pos[i] = -u.X;
        mx = st - 1;
    }
    forn(i, 0, n) cout << pos[i] << ' '; cout << '\n';
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef OFFLINE
    freopen("input.inp", "r", stdin);
    #endif
    if (MQ == true)
    {
        rd(REPIT);
    }
    while (REPIT--) Solve();
    cout.flush();
    #ifdef OFFLINE
    fclose(stdin);
    #endif
}


#include <bits/stdc++.h>
#define _itr ::iterator
#define forn(i, x, y) for (ll i = x; i < y; ++i)
#define ford(i, x, y) for (ll i = x; i > y; --i)
#define forne(i, x, y) for (ll i = x; i <= y; ++i)
#define forde(i, x, y) for (ll i = x; i >= y; --i)
#define rd(x) cin >> x; cin.ignore();
#define rdstr(x) getline(cin, x);
#define rdarr(x, y) for (ll i = 0; i < y; ++i) cin >> x[i];
#define rdmtr(x, y, z) for (ll i = 0; i < y; ++i) for (ll j = 0; j < z; ++j) cin >> x[i][j];
#define pb push_back

#define X first
#define Y second

using namespace std;
typedef long long ll;
typedef long double ld;

const ll MaxN = 1e5 + 7;
const ll MaxM = 1e2 + 7;
const ll MDL = 1e9 + 7;
const ll INF = 1e18 + 7;

typedef pair<ll, ll> pi;
typedef vector<ll> vi;
typedef ll arr[MaxN];

ll REPIT = 1;

const bool MQ = true;

ll n, m;
arr so;
map<ll, vector<ll> > mp;
priority_queue<pi> res;
arr pos;

void Solve()
{
    cin >> n; rdarr(so, n); mp.clear();
    forn(i, 0, n) mp[so[i]].push_back(i);
    for (auto v : mp)
    {
        ll u = v.X; vi p = v.Y;
        ll r = max(p.front() + 1, n - p.back());
        for (ll i = 1; i < (ll)p.size(); ++i) r = max(p[i] - p[i - 1], r);
        res.push({-u, -(r - 1)});
//        cout << u << ' ' << r << '\n';
    }
    ll mx = n - 1;
    fill(pos, pos + n, -1);
    while (!res.empty())
    {
        pi u = res.top(); res.pop();
        ll st = -u.Y; if (st > mx) continue;
        forne(i, st, mx) pos[i] = -u.X;
        mx = st - 1;
    }
    forn(i, 0, n) cout << pos[i] << ' '; cout << '\n';
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef OFFLINE
    freopen("input.inp", "r", stdin);
    #endif
    if (MQ == true)
    {
        rd(REPIT);
    }
    while (REPIT--) Solve();
    cout.flush();
    #ifdef OFFLINE
    fclose(stdin);
    #endif
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main(int argc, char **argv)
{
    int t;cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> in;
        int mi[30001];
        fill(begin(mi),end(mi),0);
        for(int i=0;i<n;i++){
            int b;cin>>b;
            in.push_back(b);
            mi[b]+=1;
        }
        for(int i=0;i<n;i++){
            //i-length
            set<int> checkset;
            for(int j=0;j<30001;j++){
                if(mi[j]>n/(i*2+3))
                    checkset.insert(j);
            }
            int mini=999999;
            for(int j:checkset){
                vector<int> ids={-1};
                for(int t=0;t<in.size();t++){
                    if(in[t]==j)ids.push_back(t);
                }
                ids.push_back(n);
                if(ids.size()>2){
                    for(int t=1;t<ids.size();t++){
                        ids[t-1]=ids[t]-ids[t-1];
                    }
                    ids.pop_back();
                    auto m = max_element(ids.begin(),ids.end());
                    if(m!=ids.end()&&*m<=i+1){
                        mini=j;
                        break;
                    }

                }
            }
            if(mini==999999)
                cout<<-1<<' ';
            else
                cout<<mini<<' ';
        }
        cout<<endl;
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

vector<int>in[300005];
int ouar[300005];

int main(int argc, char **argv)
{
    int t;cin>>t;
    while(t--){
        int n;
        cin>>n;

        for(int i=0;i<300005;i++){
            ouar[i]=300005;
            in[i]=vector<int>();
        }
        int inpmax=0;
        for(int i=0;i<n;i++){
            int b;cin>>b;
            inpmax = (b>inpmax)?(b):(inpmax);
            in[b].push_back(i);
        }
        for(int i=0;i<=inpmax;i++){
            if(in[i].size()>0){
                in[i].insert(in[i].begin(),-1);
                in[i].push_back(n);
                int maxdelta = 0;
                for(int j=0;j<in[i].size()-1;j++){
                    maxdelta = max( maxdelta , in[i][j+1]-in[i][j]);
                }
                ouar[maxdelta] = min(ouar[maxdelta] , i);
            }
        }
        int lastcout = 300005;
        for(int i=1;i<=n;i++){
            if(ouar[i]!=300005)
                cout<<min(ouar[i],lastcout)<<' ';
            else if(lastcout!=300005)
                cout<<lastcout<<' ';
            else
                cout<<"-1 ";
            lastcout= min(ouar[i],lastcout);
        }
        cout<<endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
//#include <bits/stdc++.h>
using namespace std;

int readint(){
    int u;cin>>u;
    return u;
}

int main(int argc, char **argv)
{
    int t = readint();

    int vss[300005],
        last [300005],
        maxdt [300005];
    int ou[300005];
    while ((t--) != 0) {
        int inpcount = readint();
        vector<int> inp;
        for(int i=0;i<inpcount;i++)inp.push_back(readint());
        int inpmax = *max_element(inp.begin(),inp.end()); //max
        for (int i = 1; i <= inpmax; i++) {
            last[i]=(-1);
            maxdt[i] = (-1);
        }
        for (int i = 0; i < inpcount; i++) {
            ou[i]=-1;
            int inpi = inp[i];
            maxdt[inpi] = max(i - last[inpi], maxdt[inpi]);
            last[inpi] = i;
        }
        for (int i = 0; i <= inpmax; i++) {
            maxdt[i] = max(inpcount - last[i], maxdt[i]);
        }

        //string ou = "";
        for (int i = 1; i <= inpcount; i++) {
            //print(maxdt)
            for (int j = 1; j <= inpmax; j++) {
                if (maxdt[j] <= i) {
                    ou[i - 1] = (j);
                    break;
                }
            }
        }
        for(int i=0;i<inpcount;i++){
            cout<<ou[i]<<' ';
        }
        cout<<endl;
        //print(ou.slice(0,inpcount))//string.Join(" ",ou,0,inpcount));
    }
    //cout<<out<<endl;
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int readint(){
    int u;cin>>u;
    return u;
}

int main(int argc, char **argv)
{
    int t = readint();

    int last [300005],
        maxdt [300005];
    int ou[300005];
    while ((t--) != 0) {
        int inpcount = readint();

        int inpmax = 0; //max
        for (int i = 0; i < inpcount; i++) {
            ou[i]=-1;
            int inpi = readint();
            if(inpi>inpmax)inpmax=inpi;
            maxdt[inpi] = max(i - last[inpi], maxdt[inpi]);
            last[inpi] = i;
        }
        for (int i = 1; i <= inpmax; i++) {
            last[i]=(-1);
            maxdt[i] = (-1);
        }
        for (int i = 0; i <= inpmax; i++) {
            maxdt[i] = max(inpcount - last[i], maxdt[i]);
        }

        //string ou = "";
        for (int i = 1; i <= inpcount; i++) {
            //print(maxdt)
            for (int j = 1; j <= inpmax; j++) {
                if (maxdt[j] <= i) {
                    ou[i - 1] = (j);
                    break;
                }
            }
        }
        for(int i=0;i<inpcount;i++){
            cout<<ou[i]<<' ';
        }
        cout<<endl;
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main(int argc, char **argv)
{
    int t;cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int>in[300005];
        int ouar[300005];
        for(int i=0;i<300005;i++){
            ouar[i]=300005;
            in[i]=vector<int>();
        }
        int inpmax=0;
        for(int i=0;i<n;i++){
            int b;cin>>b;
            inpmax = (b>inpmax)?(b):(inpmax);
            in[b].push_back(i);
        }
        for(int i=0;i<=inpmax;i++){
            if(in[i].size()>0){
                in[i].insert(in[i].begin(),-1);
                in[i].push_back(n);
                int maxdelta = 0;
                for(int j=0;j<in[i].size()-1;j++){
                    maxdelta = max( maxdelta , in[i][j+1]-in[i][j]);
                }
                ouar[maxdelta] = min(ouar[maxdelta] , i);
            }
        }
        int lastcout = 300005;
        for(int i=1;i<=n;i++){
            if(ouar[i]!=300005)
                cout<<min(ouar[i],lastcout)<<' ';
            else if(lastcout!=300005)
                cout<<lastcout<<' ';
            else
                cout<<"-1 ";
            lastcout= min(ouar[i],lastcout);
        }
        cout<<endl;
    }
    return 0;
}


#include <iostream>
#include <bits/stdc++.h>
using namespace std;

int main(int argc, char **argv)
{
    int t;cin>>t;
    while(t--){
        int n;
        cin>>n;
        vector<int> in;
        vector<int> mi(30001);
        fill(mi.begin(),mi.end(),0);
        for(int i=0;i<n;i++){
            int b;cin>>b;
            in.push_back(b);
            mi[b]+=1;
        }
        for(int i=0;i<n;i++){
            //i-length
            set<int> checkset;
            for(int j=0;j<30001;j++){
                if(mi[j]>n/(i*2+3))
                    checkset.insert(j);
            }
            int mini=999999;
            for(int j:checkset){
                vector<int> ids={-1};
                for(int t=0;t<in.size();t++){
                    if(in[t]==j)ids.push_back(t);
                }
                ids.push_back(n);
                if(ids.size()>2){
                    for(int t=1;t<ids.size();t++){
                        ids[t-1]=ids[t]-ids[t-1];
                    }
                    ids.pop_back();
                    auto m = max_element(ids.begin(),ids.end());
                    if(m!=ids.end()&&*m<=i+1&&mini>j){
                        mini=j;

                    }

                }
            }
            if(mini==999999)
                cout<<-1<<' ';
            else
                cout<<mini<<' ';
        }
        cout<<endl;
    }
    return 0;
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 300002;
int ans[MAX_N];
int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    vector<int> lastpos(n+1);
    vector<int> dist(n+1);
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(lastpos[a[i]] > 0)
        {
            if(i-lastpos[a[i]] > dist[a[i]])dist[a[i]] = i-lastpos[a[i]];
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(n-lastpos[i]+1 > dist[i])dist[i] = n-lastpos[i]+1;
    }
    int tmp=1;
    for(int i=n; i>=1; i--)
    {
        ans[i] = -1;
        for(int j=tmp; j<=n; j++)
        {
            if(dist[j] <= i)
            {
                ans[i] = j;
                tmp = j;
                break;
            }
        }
    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 3e5+2;
vector<int> lastpos;
vector<int> dist;
int ans[MAX_N];
int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    lastpos = vector<int>(n+1);
    dist = vector<int>(n+1);
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<=n; i++)
    {
        if(lastpos[a[i]] > 0)
        {
            dist[a[i]] = max(dist[a[i]], (i-lastpos[a[i]]));
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(lastpos[i] > 0)
        {
            dist[i] = max(dist[i], n-lastpos[i]+1);
        }
    }
    int last=1;
    for(int i=n; i>=1; i--)
    {
        int j = last;
        ans[i] = -1;
        for( ; j<=n; j++)
        {
            if(dist[j] <= i && dist[j]>0)
            {
                ans[i] = j;
                last = j;
                break;
            }
        }
    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 300002;
int lastpos[MAX_N];
int dist[MAX_N];
int ans[MAX_N];
int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    memset(lastpos,0,n*8);
    memset(dist,0,n*8);
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(lastpos[a[i]] > 0)
        {
            if(i-lastpos[a[i]] > dist[a[i]])dist[a[i]] = i-lastpos[a[i]];
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(n-lastpos[i]+1 > dist[i])dist[i] = n-lastpos[i]+1;
    }
    int tmp=1;
    for(int i=n; i>=1; i--)
    {
        ans[i] = -1;
        for(int j=tmp; j<=n; j++)
        {
            if(dist[j] <= i)
            {
                ans[i] = j;
                tmp = j;
                break;
            }
        }
    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 3e5+2;
int ans[MAX_N];
int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    vector<int> lastpos(n+1);
    vector<int> dist(n+1);
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(lastpos[a[i]] > 0)
        {
            if(i-lastpos[a[i]] > dist[a[i]])dist[a[i]] = i-lastpos[a[i]];
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(n-lastpos[i]+1 > dist[i])dist[i] = n-lastpos[i]+1;
    }
    int tmp=1;
    for(int i=n; i>=1; i--)
    {
        ans[i] = -1;
        for(int j=tmp; j<=n; j++)
        {
            if(dist[j] <= i)
            {
                ans[i] = j;
                tmp = j;
                break;
            }
        }
    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 300002;
//int lastpos[MAX_N];
//int dist[MAX_N];
//int ans[MAX_N];
//int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    vector<int> ans(n+1);
    vector<int> a(n+1);
    vector<int> lastpos(n+1);
    vector<int> dist(n+1);
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(lastpos[a[i]] > 0)
        {
            if(i-lastpos[a[i]] > dist[a[i]])dist[a[i]] = i-lastpos[a[i]];
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(n-lastpos[i]+1 > dist[i])dist[i] = n-lastpos[i]+1;
    }
    int tmp=1;
    for(int i=n; i>=1; i--)
    {
        ans[i] = -1;
        int flag = false;
        for(int j=tmp; j<=n; j++)
        {
            if(dist[j] <= i)
            {
                ans[i] = j;
                tmp = j;
                flag = true;
            }
            if(flag == true)break;
        }
    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
using namespace std;
const ll MAX_N = 3e5+2;
ll ans[MAX_N];
ll a[MAX_N];
void solve()
{
    ll n;
    cin>>n;
    vector<ll> lastpos(n+1);
    vector<ll> dist(n+1);
    for(ll i=1; i<=n; i++)cin>>a[i];
    for(ll i=1; i<=n; i++)
    {
        if(lastpos[a[i]] > 0)
        {
            if(i-lastpos[a[i]] > dist[a[i]])dist[a[i]] = i-lastpos[a[i]];
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(ll i=1; i<=n; i++)
    {
        if(lastpos[i] > 0)
        {
            if(n-lastpos[i]+1 > dist[i])dist[i] = n-lastpos[i]+1;
        }
    }
    ll last=1;
    for(ll i=n; i>=1; i--)
    {
        ans[i] = -1;
        for(ll j=last; j<=n; j++)
        {
            if(dist[j] <= i && dist[j]>0)
            {
                ans[i] = j;
                last = j;
                break;
            }
        }
    }
    for(ll i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 3e5+2;
//vector<int> lastpos(MAX_N);
//vector<int> dist(MAX_N);
int ans[MAX_N];
int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    vector<int> lastpos(n+1);
    vector<int> dist(n+1);
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<=n; i++)
    {
        if(lastpos[a[i]] > 0)
        {
            dist[a[i]] = max(dist[a[i]], (i-lastpos[a[i]]));
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(lastpos[i] > 0)
        {
            dist[i] = max(dist[i], n-lastpos[i]+1);
        }
    }
    int last=1;
    for(int i=n; i>=1; i--)
    {
        ans[i] = -1;
        for(int j=last ; j<=n; j++)
        {
            if(dist[j] <= i && dist[j]>0)
            {
                ans[i] = j;
                last = j;
                break;
            }
        }
    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 3e5+2;
vector<int> lastpos;
vector<int> dist;
int ans[MAX_N];
int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    lastpos = vector<int>(n+1);
    dist = vector<int>(n+1);
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<=n; i++)
    {
        if(lastpos[a[i]] > 0)
        {
            dist[a[i]] = max(dist[a[i]], (i-lastpos[a[i]]));
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(lastpos[i] > 0)
        {
            dist[i] = max(dist[i], n-lastpos[i]+1);
        }
    }
    int last=1;
    for(int i=n; i>=1; i--)
    {
        int j = last;
        ans[i] = -1;
        for( ; j<=n; j++)
        {
            if(dist[j] <= i && dist[j]>0)
            {
                ans[i] = j;
                break;
            }
        }
    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 3e5+2;
vector<int> lastpos;
vector<int> dist;
int ans[MAX_N];
int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    lastpos = vector<int>(n+1);
    dist = vector<int>(n+1);
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<=n; i++)
    {
        if(lastpos[a[i]] > 0)
        {
            dist[a[i]] = max(dist[a[i]], (i-lastpos[a[i]]));
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)ans[i] = -1;
    for(int i=1; i<=n; i++)
    {
        if(lastpos[i] > 0)
        {
            dist[i] = max(dist[i], n-lastpos[i]+1);
            for(int j=dist[i]; j<=n && ans[j] == -1; j++)
            {
                ans[j] = i;
            }
        }
    }
//    int last=1;
//    for(int i=n; i>=1; i--)
//    {
//        int j = last;
//        ans[i] = -1;
//        for( ; j<=n; j++)
//        {
//            if(dist[j] <= i && dist[j]>0)
//            {
//                ans[i] = j;
//                break;
//            }
//        }
//    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 3e5+2;
int ans[MAX_N];
int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    vector<int> lastpos(n+1);
    vector<int> dist(n+1);
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<=n; i++)
    {
        if(lastpos[a[i]] > 0)
        {
            if(i-lastpos[a[i]] > dist[a[i]])dist[a[i]] = i-lastpos[a[i]];
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(n-lastpos[i]+1 > dist[i])dist[i] = n-lastpos[i]+1;
    }
    int tmp=1;
    for(int i=n; i>=1; i--)
    {
        ans[i] = -1;
        for(int j=tmp; j<=n; j++)
        {
            if(dist[j] <= i)
            {
                ans[i] = j;
                tmp = j;
                break;
            }
        }
    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 3e6+2;
int ans[MAX_N];
int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    vector<int> lastpos(n+1);
    vector<int> dist(n+1);
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(lastpos[a[i]] > 0)
        {
            if(i-lastpos[a[i]] > dist[a[i]])dist[a[i]] = i-lastpos[a[i]];
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(n-lastpos[i]+1 > dist[i])dist[i] = n-lastpos[i]+1;
    }
    int tmp=1;
    for(int i=n; i>=1; i--)
    {
        ans[i] = -1;
        for(int j=tmp; j<=n; j++)
        {
            if(dist[j] <= i)
            {
                ans[i] = j;
                tmp = j;
                break;
            }
        }
    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 3e5+2;
//vector<int> lastpos(MAX_N);
//vector<int> dist(MAX_N);
int ans[MAX_N];
int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    vector<int> lastpos(n+1);
    vector<int> dist(n+1);
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<=n; i++)
    {
        if(lastpos[a[i]] > 0)
        {
            dist[a[i]] = max(dist[a[i]], (i-lastpos[a[i]]));
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(lastpos[i] > 0)
        {
            dist[i] = max(dist[i], n-lastpos[i]+1);
        }
    }
    int last=1;
    for(int i=n; i>=1; i--)
    {
        ans[i] = -1;
        for(int j=last ; j<=n; j++)
        {
            if(dist[j] <= i && dist[j]>0)
            {
                ans[i] = j;
                last = j;
                break;
            }
        }
    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 300010;
int ans[MAX_N];
int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    vector<int> lastpos(n+1);
    vector<int> dist(n+1);
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(lastpos[a[i]] > 0)
        {
            if(i-lastpos[a[i]] > dist[a[i]])dist[a[i]] = i-lastpos[a[i]];
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(n-lastpos[i]+1 > dist[i])dist[i] = n-lastpos[i]+1;
    }
    int tmp=1;
    for(int i=n; i>=1; i--)
    {
        ans[i] = -1;
        for(int j=tmp; j<=n; j++)
        {
            if(dist[j] <= i)
            {
                ans[i] = j;
                tmp = j;
                break;
            }
        }
    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 3e5+2;
int ans[MAX_N];
int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    vector<int> lastpos(n+1);
    vector<int> dist(n+1);
    for(int i=1; i<=n; i++)cin>>a[i];
    for(int i=1; i<=n; i++)
    {
        if(lastpos[a[i]] > 0)
        {
            if(i-lastpos[a[i]] > dist[a[i]])dist[a[i]] = i-lastpos[a[i]];
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(lastpos[i] > 0)
        {
            if(n-lastpos[i]+1 > dist[i])dist[i] = n-lastpos[i]+1;
        }
    }
    int last=1;
    for(int i=n; i>=1; i--)
    {
        ans[i] = -1;
        for(int j=last ; j<=n; j++)
        {
            if(dist[j] <= i && dist[j]>0)
            {
                ans[i] = j;
                last = j;
                break;
            }
        }
    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAX_N = 300002;
int lastpos[MAX_N];
int dist[MAX_N];
int ans[MAX_N];
int a[MAX_N];
void solve()
{
    int n;
    cin>>n;
    memset(lastpos,0,n*8);
    memset(dist,0,n*8);
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(lastpos[a[i]] > 0)
        {
            if(i-lastpos[a[i]] > dist[a[i]])dist[a[i]] = i-lastpos[a[i]];
            lastpos[a[i]] = i;
        }
        else
        {
            lastpos[a[i]] = i;
            dist[a[i]] = i;
        }
    }
    for(int i=1; i<=n; i++)
    {
        if(n-lastpos[i]+1 > dist[i])dist[i] = n-lastpos[i]+1;
    }
    int tmp=1;
    for(int i=n; i>=1; i--)
    {
        ans[i] = -1;
        int flag = false;
        for(int j=tmp; j<=n; j++)
        {
            if(dist[j] <= i)
            {
                ans[i] = j;
                tmp = j;
                flag = true;
            }
            if(flag == true)break;
        }
    }
    for(int i=1; i<=n; i++)cout<<ans[i]<<" ";
    cout<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    cin>>t;
    while(t--)solve();
}


#include <bits/stdc++.h>
#define ull unsigned long long
#define maxLen 3163
#define test1 cout << "test1\n";
#define test2 cout << "test2\n";
#define test3 cout << "test3\n";
#define ll long long
using namespace std;

const int MxN = 300005;

vector<int>v(MxN);
vector<int>ans(MxN);
map<int, vector<int> > reps;
map<int, int> max_k;
set<int> nums;

int max_interval( vector<int> &arr ){
    int ans = INT_MIN;
    for(int i=1; i<arr.size(); i++){
        ans = max(ans, arr[i] - arr[i-1] );
    }
    return ans;
}

int main(){
#include <bits/stdc++.h>
#define ull unsigned long long
#define maxLen 3163
#define test1 cout << "test1\n";
#define test2 cout << "test2\n";
#define test3 cout << "test3\n";
#define ll long long
using namespace std;

const int MxN = 300005;

vector<int>v(MxN);
vector<int>ans(MxN);
map<int, vector<int> > reps;
map<int, int> max_k;
set<int> nums;

int max_interval( vector<int> &arr ){
    int ans = INT_MIN;
    for(int i=1; i<arr.size(); i++){
        ans = max(ans, arr[i] - arr[i-1] );
    }
    return ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--){
        nums.clear();
        max_k.clear();
        reps.clear();
        int n,T;
        cin >> n;
        // cout << reps[0].size() << endl;
        for(int i=0; i<n; i++){
            ans[i] = -1;
            cin >> v[i];
            if( reps.find(v[i]) == reps.end() ){
                reps[v[i]].push_back(-1);
            }
            nums.insert(v[i]);
            reps[ v[i] ].push_back(i);
        }
        ans[n] = -1;

        for(map<int, vector<int> >::iterator it=reps.begin(); it!=reps.end(); it++){
            it->second.push_back(n);

           // cout << it->first<<" - " << it->second.size() <<" \n";
            //cout << it->second[0] <<" " << it->second[1] << endl;
            max_k[ it->first ] = max_interval(it->second);
          //  cout << max_k[it->first] << endl;
        }//cout <<" \n ------- \n";

        int lastIndex = n-1;
         ans[ n ] =  *nums.begin();
        while(!nums.empty()){
            int currNum = *nums.begin();
            //cout << currNum << endl;
            nums.erase(nums.begin());
            int newIndex = max_k[currNum];
            while(lastIndex >= newIndex){
                ans[lastIndex--] = currNum;
            }

        }

        for(int i=1; i<=n; i++){
            cout << ans[i] <<" ";
        }
        cout << "\n";
    }
    return 0;
}
    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--){
        max_k.clear();
        reps.clear();
        nums.clear();
        int n,T;
        cin >> n;
        // cout << reps[0].size() << endl;
        for(int i=0; i<n; i++){
            ans[i] = -1;
            cin >> v[i];
            if( reps.find(v[i]) == reps.end() ){
                reps[v[i]].push_back(-1);
            }
            nums.insert(v[i]);
            reps[ v[i] ].push_back(i);
        }
        ans[n] = -1;

        for(map<int, vector<int> >::iterator it=reps.begin(); it!=reps.end(); it++){
            it->second.push_back(n);

           // cout << it->first<<" - " << it->second.size() <<" \n";
            //cout << it->second[0] <<" " << it->second[1] << endl;
            max_k[ it->first ] = max_interval(it->second);
            //cout << max_k[it->first] << endl;
        }// <<" \n ------- \n";

        int lastIndex = n-1;
        ans[ n ] =  *nums.begin();
        while(!nums.empty()){
            int currNum = *nums.begin();
            //cout << currNum << endl;
            nums.erase(nums.begin());
            int newIndex = max_k[currNum];
            while(lastIndex >= newIndex){
                ans[lastIndex--] = currNum;
            }

        }

        for(int i=1; i<=n; i++){
            cout << ans[i] <<" ";
        }
        cout << "\n";
    }
    return 0;
}
/*
5
7
2 3 4 4 1 2 3
*/


#include <bits/stdc++.h>
#define ull unsigned long long
#define maxLen 3163
#define test1 cout << "test1\n";
#define test2 cout << "test2\n";
#define test3 cout << "test3\n";
#define ll long long
using namespace std;

const int MxN = 300005;

vector<int>v(MxN);
vector<int>ans(MxN);
map<int, vector<int> > reps;
map<int, int> max_k;
priority_queue<int> nums;

int max_interval( vector<int> &arr ){
    int ans = INT_MIN;
    for(int i=1; i<arr.size(); i++){
        ans = max(ans, arr[i] - arr[i-1] );
    }
    return ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--){
        max_k.clear();
        reps.clear();
        int n,T;
        cin >> n;
        // cout << reps[0].size() << endl;
        for(int i=0; i<n; i++){
            ans[i] = -1;
            cin >> v[i];
            if( reps.find(v[i]) == reps.end() ){
                reps[v[i]].push_back(-1);
            }
            nums.push(-1*v[i]);
            reps[ v[i] ].push_back(i);
        }
        ans[n] = -1;

        for(map<int, vector<int> >::iterator it=reps.begin(); it!=reps.end(); it++){
            it->second.push_back(n);

           // cout << it->first<<" - " << it->second.size() <<" \n";
            //cout << it->second[0] <<" " << it->second[1] << endl;
            max_k[ it->first ] = max_interval(it->second);
            //cout << max_k[it->first] << endl;
        }// <<" \n ------- \n";

        int lastIndex = n-1;
        ans[ n ] =  -1*nums.top();
        while(!nums.empty()){
            int currNum = -1*nums.top();
            //cout << currNum << endl;
            nums.pop();
            int newIndex = max_k[currNum];
            while(lastIndex >= newIndex){
                ans[lastIndex--] = currNum;
            }

        }

        for(int i=1; i<=n; i++){
            cout << ans[i] <<" ";
        }
        cout << "\n";
    }
    return 0;
}
/*
5
7
2 3 4 4 1 2 3
*/


#include <bits/stdc++.h>
#define ull unsigned long long
#define maxLen 3163
#define test1 cout << "test1\n";
#define test2 cout << "test2\n";
#define test3 cout << "test3\n";
#define ll long long
using namespace std;

const int MxN = 300005;

vector<int>v(MxN);
vector<int>ans(MxN);
map<int,bool>vis;
map<int, vector<int> > reps;
map<int, int> max_k;
priority_queue<int> nums;

int max_interval( vector<int> &arr ){
    int ans = INT_MIN;
    for(int i=1; i<arr.size(); i++){
        ans = max(ans, arr[i] - arr[i-1] );
    }
    return ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--){
        max_k.clear();
        reps.clear();
        vis.clear();
        int n,T;
        cin >> n;
        // cout << reps[0].size() << endl;
        for(int i=0; i<n; i++){
            ans[i] = -1;
            cin >> v[i];
            if( reps.find(v[i]) == reps.end() ){
                reps[v[i]].push_back(-1);
            }
            if(!vis[v[i]])
            nums.push(-1*v[i]);
            reps[ v[i] ].push_back(i);
            vis[v[i]]=1;
        }
        ans[n] = -1;

        for(map<int, vector<int> >::iterator it=reps.begin(); it!=reps.end(); it++){
            it->second.push_back(n);

           // cout << it->first<<" - " << it->second.size() <<" \n";
            //cout << it->second[0] <<" " << it->second[1] << endl;
            max_k[ it->first ] = max_interval(it->second);
            //cout << max_k[it->first] << endl;
        }// <<" \n ------- \n";

        int lastIndex = n-1;
        ans[ n ] =  -1*nums.top();
        while(!nums.empty()){
            int currNum = -1*nums.top();
            //cout << currNum << endl;
            nums.pop();
            int newIndex = max_k[currNum];
            while(lastIndex >= newIndex){
                ans[lastIndex--] = currNum;
            }

        }

        for(int i=1; i<=n; i++){
            cout << ans[i] <<" ";
        }
        cout << "\n";
    }
    return 0;
}
/*
5
7
2 3 4 4 1 2 3
*/


#include <bits/stdc++.h>
#define ull unsigned long long
#define maxLen 3163
#define test1 cout << "test1\n";
#define test2 cout << "test2\n";
#define test3 cout << "test3\n";
#define ll long long
using namespace std;

const int MxN = 300005;

vector<int>v(MxN);
vector<int>ans(MxN);
map<int, vector<int> > reps;
map<int, int> max_k;
set<int> nums;

int max_interval( vector<int> &arr ){
    int ans = INT_MIN;
    for(int i=1; i<arr.size(); i++){
        ans = max(ans, arr[i] - arr[i-1] );
    }
    return ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--){
        max_k.clear();
        reps.clear();
        nums.clear();
        int n,T;
        cin >> n;
        // cout << reps[0].size() << endl;
        for(int i=0; i<n; i++){
            ans[i] = -1;
            cin >> v[i];
            if( reps.find(v[i]) == reps.end() ){
                reps[v[i]].push_back(-1);
            }
            nums.insert(v[i]);
            reps[ v[i] ].push_back(i);
        }
        ans[n] = -1;

        for(map<int, vector<int> >::iterator it=reps.begin(); it!=reps.end(); it++){
            it->second.push_back(n);

           // cout << it->first<<" - " << it->second.size() <<" \n";
            //cout << it->second[0] <<" " << it->second[1] << endl;
            max_k[ it->first ] = max_interval(it->second);
            //cout << max_k[it->first] << endl;
        }// <<" \n ------- \n";

        int lastIndex = n-1;
        ans[ n ] =  *nums.begin();
        while(!nums.empty()){
            int currNum = *nums.begin();
            //cout << currNum << endl;
            nums.erase(nums.begin());
            int newIndex = max_k[currNum];
            while(lastIndex >= newIndex){
                ans[lastIndex--] = currNum;
            }

        }

        for(int i=1; i<=n; i++){
            cout << ans[i] <<" ";
        }
        cout << "\n";
    }
    return 0;
}
/*
5
7
2 3 4 4 1 2 3
*/


#include <bits/stdc++.h>
#define ull unsigned long long
#define maxLen 3163
#define test1 cout << "test1\n";
#define test2 cout << "test2\n";
#define test3 cout << "test3\n";
#define ll long long
using namespace std;

const int MxN = 300005;

vector<int>v(MxN);
vector<int>ans(MxN);
map<int, vector<int> > reps;
map<int, int> max_k;
set<int> nums;

int max_interval( vector<int> &arr ){
    int ans = INT_MIN;
    for(int i=1; i<arr.size(); i++){
        ans = max(ans, arr[i] - arr[i-1] );
    }
    return ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--){
        nums.clear();
        max_k.clear();
        reps.clear();
        int n,T;
        cin >> n;
        // cout << reps[0].size() << endl;
        for(int i=0; i<n; i++){
            ans[i] = -1;
            cin >> v[i];
            if( reps.find(v[i]) == reps.end() ){
                reps[v[i]].push_back(-1);
            }
            nums.insert(v[i]);
            reps[ v[i] ].push_back(i);
        }
        ans[n] = -1;

        for(map<int, vector<int> >::iterator it=reps.begin(); it!=reps.end(); it++){
            it->second.push_back(n);

           // cout << it->first<<" - " << it->second.size() <<" \n";
            //cout << it->second[0] <<" " << it->second[1] << endl;
            max_k[ it->first ] = max_interval(it->second);
          //  cout << max_k[it->first] << endl;
        }//cout <<" \n ------- \n";

        int lastIndex = n-1;
        ans[ n ] =  *nums.begin();
        while(!nums.empty()){
            int currNum = *nums.begin();
            //cout << currNum << endl;
            nums.erase(nums.begin());
            int newIndex = max_k[currNum];
            while(lastIndex >= newIndex){
                ans[lastIndex--] = currNum;
            }

        }

        for(int i=1; i<=n; i++){
            cout << ans[i] <<" ";
        }
        cout << "\n";
    }
    return 0;
}
/*
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
*/


#include <bits/stdc++.h>
#define ull unsigned long long
#define maxLen 3163
#define test1 cout << "test1\n";
#define test2 cout << "test2\n";
#define test3 cout << "test3\n";
#define ll long long
using namespace std;

const int MxN = 300005;

vector<int>v(MxN);
vector<int>ans(MxN);
map<int, vector<int> > reps;
map<int, int> max_k;
set<int> nums;

int max_interval( vector<int> &arr ){
    int ans = INT_MIN;
    for(int i=1; i<arr.size(); i++){
        ans = max(ans, arr[i] - arr[i-1] );
    }
    return ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--){
        nums.clear();
        max_k.clear();
        reps.clear();
        int n,T;
        cin >> n;
        // cout << reps[0].size() << endl;
        for(int i=0; i<n; i++){
            ans[i] = -1;
            cin >> v[i];
            if( reps.find(v[i]) == reps.end() ){
                reps[v[i]].push_back(-1);
            }
            nums.insert(v[i]);
            reps[ v[i] ].push_back(i);
        }
        ans[n] = -1;

        for(map<int, vector<int> >::iterator it=reps.begin(); it!=reps.end(); it++){
            it->second.push_back(n);

           // cout << it->first<<" - " << it->second.size() <<" \n";
            //cout << it->second[0] <<" " << it->second[1] << endl;
            max_k[ it->first ] = max_interval(it->second);
          //  cout << max_k[it->first] << endl;
        }//cout <<" \n ------- \n";

        int lastIndex = n+1;
        while(!nums.empty() && lastIndex>0){
            int currNum = *nums.begin();
            nums.erase(nums.begin());
            int newIndex = max_k[currNum];
            for(int i=lastIndex-1; i>=newIndex; i--){
                ans[i] = currNum;
            }
            lastIndex = newIndex;

        }

        for(int i=1; i<=n; i++){
            cout << ans[i] <<" ";
        }
        cout << "\n";
    }
    return 0;
}
/*
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
*/


#include <bits/stdc++.h>
#define ull unsigned long long
#define maxLen 3163
#define test1 cout << "test1\n";
#define test2 cout << "test2\n";
#define test3 cout << "test3\n";
#define ll long long
using namespace std;

const int MxN = 300005;

vector<int>v(MxN);
vector<int>ans(MxN);
map<int, vector<int> > reps;
map<int, int> max_k;
set<int> nums;

int max_interval( vector<int> &arr ){
    int ans = INT_MIN;
    for(int i=1; i<arr.size(); i++){
        ans = max(ans, arr[i] - arr[i-1] );
    }
    return ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--){
        reps.clear();
        int n,T;
        cin >> n;
        // cout << reps[0].size() << endl;
        for(int i=0; i<n; i++){
            ans[i] = -1;
            cin >> v[i];
            if( reps.find(v[i]) == reps.end() ){
                reps[v[i]].push_back(-1);
            }
            nums.insert(v[i]);
            reps[ v[i] ].push_back(i);
        }

        for(map<int, vector<int> >::iterator it=reps.begin(); it!=reps.end(); it++){
            it->second.push_back(n);
           // cout << it->first<<" - " << it->second.size() <<" \n";
            //cout << it->second[0] <<" " << it->second[1] << endl;
            max_k[ it->first ] = max_interval(it->second);
          //  cout << max_k[it->first] << endl;
        }//cout <<" \n ------- \n";

        int lastIndex = n+1;
        while(!nums.empty() && lastIndex>0){
            int currNum = *nums.begin();
            nums.erase(nums.begin());
            int newIndex = max_k[currNum];
            for(int i=lastIndex-1; i>=newIndex; i--){
                ans[i] = currNum;
            }
            lastIndex = newIndex;

        }

        for(int i=1; i<=n; i++){
            cout << ans[i] <<" ";
        }
        cout << "\n";
    }
    return 0;
}
/*
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
*/


#include <bits/stdc++.h>
#define ull unsigned long long
#define maxLen 3163
#define test1 cout << "test1\n";
#define test2 cout << "test2\n";
#define test3 cout << "test3\n";
#define ll long long
using namespace std;

const int MxN = 300005;

vector<int>v(MxN);
vector<int>ans(MxN);
map<int, vector<int> > reps;
map<int, int> max_k;
set<int> nums;

int max_interval( vector<int> &arr ){
    int ans = INT_MIN;
    for(int i=1; i<arr.size(); i++){
        ans = max(ans, arr[i] - arr[i-1] );
    }
    return ans;
}

int main(){

    ios_base::sync_with_stdio(false);
    int t;
    cin >> t;
    while(t--){
        nums.clear();
        max_k.clear();
        reps.clear();
        int n,T;
        cin >> n;
        // cout << reps[0].size() << endl;
        for(int i=0; i<n; i++){
            ans[i] = -1;
            cin >> v[i];
            if( reps.find(v[i]) == reps.end() ){
                reps[v[i]].push_back(-1);
            }
            nums.insert(v[i]);
            reps[ v[i] ].push_back(i);
        }
        ans[n] = -1;

        for(map<int, vector<int> >::iterator it=reps.begin(); it!=reps.end(); it++){
            it->second.push_back(n);

           // cout << it->first<<" - " << it->second.size() <<" \n";
            //cout << it->second[0] <<" " << it->second[1] << endl;
            max_k[ it->first ] = max_interval(it->second);
          //  cout << max_k[it->first] << endl;
        }//cout <<" \n ------- \n";

        int lastIndex = n;
        while(!nums.empty() && lastIndex>0){
            int currNum = *nums.begin();
            nums.erase(nums.begin());
            int newIndex = max_k[currNum];
            for(; lastIndex>=newIndex; lastIndex--){
                ans[lastIndex] = currNum;
            }

        }

        for(int i=1; i<=n; i++){
            cout << ans[i] <<" ";
        }
        cout << "\n";
    }
    return 0;
}
/*
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
*/


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n);
		vector<ll> p(n+1,0), last(n+1, 0), start(n+1, 0);

		rep(i,n)
		{
			ll x;
			cin>>x;

			if(!start[x])
			{
				start[x] = i + 1;
			}

			p[x] = max(p[x], i - last[x]);
			last[x] = i;
		}

		vector<pair<ll,ll>> value;
		for(int i=1;i<=n;i++)
		{
			if(!start[i])
			{
				value.push_back({n + 1, i});
				continue;
			}

			if(p[i]==last[i])
			{
				p[i]++;
				p[i] = max(p[i], n - last[i]);
				value.push_back({p[i], i});
				continue;
			}

			p[i] = max({p[i], n - last[i], start[i]});
			value.push_back({p[i], i});
		}

		sort(value.begin(), value.end());

		//for(auto x:value) cout<<x.first<<" "<<x.second<<endl;

		vector<ll> ans(n+1,-1);
		int j = value[0].first;
		ll curr = value[0].second;

		for(int i=0;i<n;i++)
		{
			while(j < value[i].first)
			{
				if(j>=n+1) break;
				ans[j] = curr;
				j++;
			}

		    if(j>=n+1) break;
			curr = min(curr, value[i].second);
		    ans[j] = curr;

		    while(j > value[i].first) j++;
		}

		while(j<=n)
		{
			ans[j] = curr;
			j++;
		}

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

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n);
		vector<ll> p(n+1,0), last(n+1, 0), start(n+1, 0);

		rep(i,n)
		{
			ll x;
			cin>>x;

			if(!start[x])
			{
				start[x] = i + 1;
			}

			p[x] = max(p[x], i - last[x]);
			last[x] = i;
		}

		vector<pair<ll,ll>> value;
		for(int i=1;i<=n;i++)
		{
			if(!start[i])
			{
				value.push_back({n + 1, i});
				continue;
			}

			if(p[i]==last[i])
			{
				p[i]++;
				p[i] = max(p[i], n - last[i]);
				value.push_back({p[i], i});
				continue;
			}

			p[i] = max({p[i], n - last[i], start[i]});
			value.push_back({p[i], i});
		}

		//sort(value.begin(), value.end());

		for(auto x:value) cout<<x.first<<" "<<x.second<<endl;

		vector<ll> ans(n+1,-1);
		int j = value[0].first;
		ll curr = value[0].second;

		for(int i=0;i<n;i++)
		{
			while(j < value[i].first)
			{
				if(j>=n+1) break;
				ans[j] = curr;
				j++;
			}

		    if(j>=n+1) break;
			curr = min(curr, value[i].second);
		    ans[j] = curr;

		    while(j > value[i].first) j++;
		}

		while(j<=n)
		{
			ans[j] = curr;
			j++;
		}

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

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> p(n+1,0), last(n+1, 0), vis(n+1, 0);

		for(int i=1;i<=n;i++)
		{
			ll x;
			cin>>x;

			p[x] = max(p[x], i - last[x]);
			last[x] = i;
			vis[x] = 1;
		}

		vector<pair<ll,ll>> value;
		for(int i=1;i<=n;i++)
		{
			if(!vis[i])
			{
				p[i] = n + 1;
				value.push_back({p[i], i});
				continue;
			}

			p[i] = max(p[i], n + 1 - last[i]);
			value.push_back({p[i], i});
		}

		sort(value.begin(), value.end());

		//for(auto x:value) cout<<x.first<<" "<<x.second<<endl;

		vector<ll> ans(n+1,-1);
		int j = value[0].first;
		ll curr = value[0].second;

		for(int i=0;i<n;i++)
		{
			while(j < value[i].first)
			{
				if(j>=n+1) break;
				ans[j] = curr;
				j++;
			}

		    if(j>=n+1) break;
			curr = min(curr, value[i].second);
		    ans[j] = curr;

		    while(j > value[i].first) j++;
		}

		while(j<=n)
		{
			ans[j] = curr;
			j++;
		}

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

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n);
		vector<ll> p(n+1,0), last(n+1,-1);

		rep(i,n)
		{
			ll x;
			cin>>x;

			p[x] = max(p[x], i - last[x]);
			last[x] = i;
		}

		for(int i=1;i<=n;i++)
		{
			if(last[i]==-1)
			{
				p[i] = 0;
				continue;
			}

			p[i] = max(p[i], n - last[i]);
		}

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

		int j = n;
		for(int i=1;i<=n;i++)
		{
			while(p[i] and j>0 and j >= p[i])
			{
				ans[j] = i;
				j--;
			}
		}

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

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n);
		vector<ll> p(n+1,0), last(n+1,-1);

		rep(i,n) cin>>v[i];

		rep(i,n) p[v[i]] = max(p[v[i]], i - p[v[i]]), last[v[i]] = i;

		vector<pair<ll,ll>> value;
		for(int i=1;i<=n;i++)
		{
			if(p[i]==last[i]) p[i]++;

			p[i] = max(p[i], n - last[i]);
			value.push_back({p[i], i});
		}

		sort(value.begin(), value.end());

		//for(auto x:value) cout<<x.first<<" "<<x.second<<endl;

		vector<ll> ans(n+1,-1);
		int j = value[0].first;
		ll curr = value[0].second;

		for(int i=0;i<n;i++)
		{
			while(j < value[i].first)
			{
				ans[j] = curr;
				j++;
			}

		    if(j==n+1) break;
			curr = min(curr, value[i].second);
		    ans[j] = curr;

		    if(j <= value[i].first) j++;

		}

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

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n);
		vector<ll> p(n+1,0), last(n+1,-1);

		rep(i,n)
		{
			ll x;
			cin>>x;

			p[x] = max(p[x], i - last[x]);
			last[x] = i;
		}

		vector<pair<ll,ll>> value;
		for(int i=1;i<=n;i++)
		{
			if(p[i]==last[i]) p[i]++;

			p[i] = max(p[i], n - last[i]);
			value.push_back({p[i], i});
		}

		sort(value.begin(), value.end());

		//for(auto x:value) cout<<x.first<<" "<<x.second<<endl;

		vector<ll> ans(n+1,-1);
		int j = value[0].first;
		ll curr = value[0].second;

		for(int i=0;i<n;i++)
		{
			while(j < value[i].first)
			{
				if(j>=n+1) break;
				ans[j] = curr;
				j++;
			}

		    if(j>=n+1) break;
			curr = min(curr, value[i].second);
		    ans[j] = curr;

		    while(j > value[i].first) j++;
		}

		while(j<=n)
		{
			ans[j] = curr;
			j++;
		}

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

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n);
		vector<ll> p(n+1,0), last(n+1,-1);

		rep(i,n) cin>>v[i];

		rep(i,n) p[v[i]] = max(p[v[i]], i - p[v[i]]), last[v[i]] = i;

		vector<pair<ll,ll>> value;
		for(int i=1;i<=n;i++)
		{
			if(p[i]==last[i]) p[i]++;

			p[i] = max(p[i], n - last[i]);
			value.push_back({p[i], i});
		}

		sort(value.begin(), value.end());

		//for(auto x:value) cout<<x.first<<" "<<x.second<<endl;

		vector<ll> ans(n+1,-1);
		int j = value[0].first;
		ll curr = value[0].second;

		for(int i=0;i<n;i++)
		{
			while(j < value[i].first)
			{
				if(j==n+1) break;

				ans[j] = curr;
				j++;
			}

		    if(j==n+1) break;
			curr = min(curr, value[i].second);
		    ans[j] = curr;

		    if(j <= value[i].first) j++;

		}

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

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n);
		vector<ll> p(n+1,0), last(n+1,-1);

		rep(i,n) cin>>v[i];

		rep(i,n) p[v[i]] = max(p[v[i]], i - p[v[i]]), last[v[i]] = i;

		vector<pair<ll,ll>> value;
		for(int i=1;i<=n;i++)
		{
			if(p[i]==last[i]) p[i]++;

			p[i] = max(p[i], n - last[i]);
			value.push_back({p[i], i});
		}

		sort(value.begin(), value.end());

		//for(auto x:value) cout<<x.first<<" "<<x.second<<endl;

		vector<ll> ans(n+1,-1);
		int j = value[0].first;
		ll curr = value[0].second;

		for(int i=0;i<n;i++)
		{
			while(j < value[i].first)
			{
				ans[j] = curr;
				j++;

				if(j==n+1) break;
			}

		    if(j==n+1) break;
			curr = min(curr, value[i].second);
		    ans[j] = curr;

		    if(j <= value[i].first) j++;

		}

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

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n);
		vector<ll> p(n+1,0), last(n+1,-1);

		rep(i,n)
		{
			ll x;
			cin>>x;

			p[x] = max(p[x], i - last[x]);
			last[x] = i;
		}

		vector<pair<ll,ll>> value;
		for(int i=1;i<=n;i++)
		{
			if(p[i]==last[i]) p[i]++;

			p[i] = max(p[i], n - last[i]);
			value.push_back({p[i], i});
		}

		sort(value.begin(), value.end());

		//for(auto x:value) cout<<x.first<<" "<<x.second<<endl;

		vector<ll> ans(n+1,-1);
		int j = value[0].first;
		ll curr = value[0].second;

		for(int i=0;i<n;i++)
		{
			while(j < value[i].first)
			{
				if(j==n+1) break;
				ans[j] = curr;
				j++;
			}

		    if(j==n+1) break;
			curr = min(curr, value[i].second);
		    ans[j] = curr;

		    if(j <= value[i].first) j++;
		}

		while(j<=n)
		{
			ans[j] = curr;
			j++;
		}

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

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n);
		vector<ll> p(n+1,0), last(n+1,-1);

		rep(i,n) cin>>v[i];

		rep(i,n) p[v[i]] = max(p[v[i]], i - p[v[i]]), last[v[i]] = i;

		vector<pair<ll,ll>> value;
		for(int i=1;i<=n;i++)
		{
			if(p[i]==last[i]) p[i]++;

			p[i] = max(p[i], n - last[i]);
			value.push_back({p[i], i});
		}

		sort(value.begin(), value.end());

		//for(auto x:value) cout<<x.first<<" "<<x.second<<endl;

		vector<ll> ans(n+1,-1);
		int j = value[0].first;
		ll curr = value[0].second;

		for(int i=0;i<n;i++)
		{
			while(j < value[i].first)
			{
				if(j==n+1) break;
				ans[j] = curr;
				j++;
			}

		    if(j==n+1) break;
			curr = min(curr, value[i].second);
		    ans[j] = curr;

		    if(j <= value[i].first) j++;
		}

		while(j<=n)
		{
			ans[j] = curr;
			j++;
		}

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

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define fastIO          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll              long long
#define double          long double
#define rep(i,a)        for(ll i = 0 ; i < a ; i++)
#define repe(i,a,b)     for(ll i = a ; i < b ; i++)
#define bac(i,a)        for(ll i = a ; i >= 0 ; i--)
#define bace(i,a,b)     for(ll i = a ; i >= b ; i--)
#define pb              push_back
#define mp              make_pair
#define in              insert
#define ff              first
#define ss              second
#define vv              vector
#define vll             vector <ll>
#define pll             pair <ll,ll>
#define vpll            vector <pll>
#define umap            unordered_map
#define uset            unordered_set
#define mset            multiset
#define pqueue          priority_queue
#define stk             stack<ll>
#define que             queue<ll>
#define setbit(x)       __builtin_popcountll(x)
#define init(c,a)       memset(c,a,sizeof(c))
#define all(c)          c.begin(),c.end()
#define lb              lower_bound
#define ub              upper_bound
#define maxe            *max_element
#define mine            *min_element
#define gcd(a,b)        __gcd(a,b)
#define lcm(a,b)        a/__gcd(a,b)*b
#define Y               "YES"
#define N               "NO"
#define endl            "\n"
#define debug(x)        cout << #x << " : " << x << nl;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ll inf = 1e18;
const ll MAX = 2e5 + 1;

inline ll add(ll a,ll b) {return ((a%mod)+(b%mod))%mod;}
inline ll sub(ll a,ll b) {return ((a%mod)-(b%mod)+mod)%mod;}
inline ll mul(ll a,ll b) {return ((a%mod)*(b%mod))%mod;}

ll pwr(ll x,ll n){
	x=x%mod;
    if(!n) return 1;
    if(n&1) return mul(x, pwr(mul(x,x),(n-1)/2));
    else return pwr(mul(x,x),n/2);
}
// O(nlogn) for [1,n]
ll modinv(ll n){
    return pwr(n,mod - 2);
}
// O(logn) for[1,n]
ll inv(ll i){
    if(i==1) return 1;
    return (mod-(mod/i)*inv(mod%i)%mod)%mod;
}
// =============================
bool f(int a,int b)
{
	return a>b;
}
struct cmp{
	bool operator()(const int &k1, const int &k2){
        return k1>k2;
    }
};
// ==============================
// ==============================
// ======Useful Code Begins======

int main()
{
	fastIO;
	int tt = 1;
	cin>>tt;

	while(tt--)
	{
		int n;
		cin>>n;

		vector<ll> v(n);
		vector<ll> p(n+1,0), last(n+1,-1);

		rep(i,n)
		{
			ll x;
			cin>>x;

			p[x] = max(p[x], i - last[x]);
			last[x] = i;
		}

		vector<pair<ll,ll>> value;
		for(int i=1;i<=n;i++)
		{
			if(p[i]==last[i])
			{
				p[i]++;
				p[i] = max(p[i], n + 1 - last[i]);
				value.push_back({p[i], i});
				continue;
			}

			p[i] = max(p[i], n - last[i]);
			value.push_back({p[i], i});
		}

		sort(value.begin(), value.end());

		//for(auto x:value) cout<<x.first<<" "<<x.second<<endl;

		vector<ll> ans(n+1,-1);
		int j = value[0].first;
		ll curr = value[0].second;

		for(int i=0;i<n;i++)
		{
			while(j < value[i].first)
			{
				if(j>=n+1) break;
				ans[j] = curr;
				j++;
			}

		    if(j>=n+1) break;
			curr = min(curr, value[i].second);
		    ans[j] = curr;

		    while(j > value[i].first) j++;
		}

		while(j<=n)
		{
			ans[j] = curr;
			j++;
		}

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

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
	ll n,a;
	cin>>n;
	ll has[n+5];
	vector<ll> v[n+5];
	for(ll i=1;i<=n;i++) has[i]=-1;
	for(ll i=1;i<=n;i++) v[i].push_back(0);
	for(ll i=1;i<=n;i++)
	{
		cin>>a;
		v[a].push_back(i);
	}
	ll las=n;
	for(ll i=1;i<=n;i++)
	{
		if(v[i].size()==1) continue;
		v[i].push_back(n+1);
		ll m=-1;
		for(ll j=1;j<v[i].size();j++)
		{
			m=max(m,v[i][j]-v[i][j-1]-1);
		}
		for(ll j=m+1;j<=las;j++) has[j]=i;
		las=m;
	}
	for(ll i=1;i<=n;i++) cout<<has[i]<<" ";
	cout<<endl;
}
int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
void solve()
{
	int n,a;
	cin>>n;
	int has[n+5];
	vector<int> v[n+5];
	for(int i=1;i<=n;i++) has[i]=-1;
	for(int i=1;i<=n;i++) v[i].push_back(0);
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		v[a].push_back(i);
	}
	int las=n;
	for(int i=1;i<=n;i++)
	{
		if(v[i].size()==1) continue;
		v[i].push_back(n+1);
		int m=-1;
		for(int j=1;j<v[i].size();j++)
		{
			m=max(m,v[i][j]-v[i][j-1]);
		}
		for(int j=m;j<=las;j++) has[j]=i;
		las=m-1;
	}
	for(int i=1;i<=n;i++) cout<<has[i]<<" ";
	cout<<endl;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
	ll n,a;
	cin>>n;
	ll has[n+5];
	vector<ll> v[n+5];
	for(ll i=1;i<=n;i++) v[i].clear(),has[i]=-1;
	for(ll i=1;i<=n;i++) v[i].push_back(0);
	for(ll i=1;i<=n;i++)
	{
		cin>>a;
		v[a].push_back(i);
	}
	ll las=n;
	for(ll i=1;i<=n;i++)
	{
		if(v[i].size()==1) continue;
		v[i].push_back(n+1);
		ll m=-1;
		for(ll j=1;j<v[i].size();j++)
		{
			m=max(m,v[i][j]-v[i][j-1]-1);
		}
		for(ll j=m+1;j<=las;j++) has[j]=i;
		las=m;
	}
	for(ll i=1;i<=n;i++) cout<<has[i]<<" ";
	cout<<endl;
}
int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
void solve()
{
	int n,a;
	cin>>n;
	int has[n+5];
	vector<int> v[n+5];
	for(int i=1;i<=n;i++) has[i]=-1;
	for(int i=1;i<=n;i++) v[i].push_back(0);
	for(int i=1;i<=n;i++)
	{
		cin>>a;
		v[a].push_back(i);
	}
	int las=n;
	for(int i=1;i<=n;i++)
	{
		if(v[i].size()==1) continue;
		v[i].push_back(n+1);
		int m=-1;
		for(int j=1;j<v[i].size();j++)
		{
			m=max(m,v[i][j]-v[i][j-1]-1);
		}
		for(int j=m+1;j<=las;j++) has[j]=i;
		las=m;
	}
	for(int i=1;i<=n;i++) cout<<has[i]<<" ";
	cout<<endl;
}
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		solve();
	}
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
	ll n,a;
	cin>>n;
	ll has[n+5];
	vector<ll> v[n+5];
	for(ll i=1;i<=n;i++) v[i].clear(),has[i]=-1;
	for(ll i=1;i<=n;i++) v[i].push_back(0);
	for(ll i=1;i<=n;i++)
	{
		cin>>a;
		v[a].push_back(i);
	}
	ll las=n;
	for(ll i=1;i<=n;i++)
	{
		if(v[i].size()==1) continue;
		v[i].push_back(n+1);
		ll m=-1;
		for(ll j=1;j<v[i].size();j++)
		{
			m=max(m,v[i][j]-v[i][j-1]);
		}
		if(m<=las)
		{
			for(ll j=m;j<=las;j++) has[j]=i;
			las=m-1;
		}
	}
	for(ll i=1;i<=n;i++) cout<<has[i]<<" ";
	cout<<endl;
}
int main()
{
	ll t;
	cin>>t;
	while(t--)
	{
		solve();
	}
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back

int main(){

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

        ll n,k;
        ll arr[100005];
        cin >> n;
        bool allSame = true;
        for(int i=1;i<=n;i++){
            cin >> arr[i];
            if(i>1){
                if(arr[i]!=arr[i-1]){
                    allSame = false;
                }
            }
        }

        if(allSame){
            for(int i=1;i<=n;i++){
                cout << arr[i]<<" ";
            }
            cout << endl;
        }
        else{
                cout << -1 <<" ";
                ll end = n/2;

                for(ll i=2;i<=end;i++){
                    allSame = true;
                    ll ele = arr[i];
                    ll j = i;
                    while(j<n){
                        if(ele!=arr[j]){
                            allSame = false;
                            break;
                        }
                        j+=i;
                    }
                    j-=i;
                    ll rem = (n-(j+i-1));
                    bool found = false;
                    for(int ii=j+rem;ii<=j+i;ii++){
                        if(arr[ii]==ele){
                            found = true ;
                            break;
                        }
                    }

                    if(!found)allSame = false;
                    if(allSame){
                        cout << ele <<" ";
                    }
                    else cout << -1<<" ";

                }

                ll p,nn;
                if(n%2==0){
                    p = n/2;
                    nn = p+1;
                }
                else {
                       p = (n+1)/2;
                       nn = p;
                }

                ll mini = 999999;
                while(p>0){
                    mini = min(min(arr[p],arr[nn]),mini);
                    cout << mini << " ";
                    p--;nn++;
                }
                cout << endl;

        }

}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back

int main(){

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

        ll n,k;
        ll arr[100005];
        cin >> n;
        bool allSame = true;
        for(int i=1;i<=n;i++){
            cin >> arr[i];
            if(i>1){
                if(arr[i]!=arr[i-1]){
                    allSame = false;
                }
            }
        }

        if(allSame){
            for(int i=1;i<=n;i++){
                cout << arr[i]<<" ";
            }
            cout << endl;
        }
        else{
                cout << -1 <<" ";
                ll end = n/2;

                for(ll i=2;i<=end;i++){
                    allSame = true;
                    ll ele = arr[i];
                    ll j = i;
                    while(j<n){
                        if(ele!=arr[j]){
                            allSame = false;
                            break;
                        }
                        j+=i;
                    }
                    if(allSame){
                        cout << ele <<" ";
                    }
                    else cout << -1<<" ";

                }

                ll p,nn;
                if(n%2==0){
                    p = n/2;
                    nn = p+1;
                }
                else {
                       p = (n+1)/2;
                       nn = p;
                }

                //cout << "p is "<<p<<" nn is "<<nn<<endl;

                ll mini = 999999;
                while(p>0){
                    mini = min(min(arr[p],arr[nn]),mini);
                    cout << mini << " ";
                    p--;nn++;
                }
                cout << endl;

        }

}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back

int main(){

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

        ll n,k;
        ll arr[100005];
        cin >> n;
        bool allSame = true;
        for(int i=1;i<=n;i++){
            cin >> arr[i];
            if(i>1){
                if(arr[i]!=arr[i-1]){
                    allSame = false;
                }
            }
        }

        if(allSame){
            for(int i=1;i<=n;i++){
                cout << arr[i]<<" ";
            }
            cout << endl;
        }
        else{
                cout << -1 <<" ";
                ll end = n/2;

                for(ll i=2;i<=end;i++){
                    allSame = true;
                    ll ele = arr[i];
                    ll j = i;
                    while(j<n){
                        if(ele!=arr[j]){
                            allSame = false;
                            break;
                        }
                        j+=i;
                    }
                    bool found = false;
                    if(allSame){
                    j-=i;
                    ll rem = (n-(j+i-1));

                    for(int ii=j+rem;ii<=j+i;ii++){
                        if(arr[ii]==ele){
                            found = true ;
                            break;
                        }
                    }
                    }

                    if(!found)allSame = false;
                    if(allSame){
                        cout << ele <<" ";
                    }
                    else cout << -1<<" ";

                }

                ll p,nn;
                if(n%2==0){
                    p = n/2;
                    nn = p+1;
                }
                else {
                       p = (n+1)/2;
                       nn = p;
                }

                ll mini = 999999;
                while(p>0){
                    mini = min(min(arr[p],arr[nn]),mini);
                    cout << mini << " ";
                    p--;nn++;
                }
                cout << endl;

        }

}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back

int main(){

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

        ll n,k;
        ll arr[100005];
        cin >> n;
        bool allSame = true;
        for(int i=1;i<=n;i++){
            cin >> arr[i];
            if(i>1){
                if(arr[i]!=arr[i-1]){
                    allSame = false;
                }
            }
        }

        if(allSame){
            for(int i=1;i<=n;i++){
                cout << arr[i]<<" ";
            }
            cout << endl;
        }
        else{
                cout << -1 <<" ";
                ll end = n/2;

                for(ll i=2;i<=end;i++){
                    allSame = true;
                    ll ele = arr[i];
                    ll j = i;
                    while(j<=n){
                        if(ele!=arr[j]){
                            allSame = false;
                            break;
                        }
                        j+=i;
                    }
                    bool found = false;
                    if(allSame && j>n){
                    j-=i;
                    ll rem = (n-(j+i-1));

                    for(int ii=j+rem;ii<=j+i;ii++){
                        if(arr[ii]==ele){
                            found = true ;
                            break;
                        }
                    }
                    }

                    if(!found)allSame = false;
                    if(allSame){
                        cout << ele <<" ";
                    }
                    else cout << -1<<" ";

                }

                ll p,nn;
                if(n%2==0){
                    p = n/2;
                    nn = p+1;
                }
                else {
                       p = (n+1)/2;
                       nn = p;
                }

                ll mini = 999999;
                while(p>0){
                    mini = min(min(arr[p],arr[nn]),mini);
                    cout << mini << " ";
                    p--;nn++;
                }
                cout << endl;

        }

}

    return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    int arr[300005];
    vector<int> v[300005];
    int ans[300005];
    vector<int> uniq;
    while(t--){
        int n;
        cin >> n;
        for(int i=0; i <= n; i++){
            v[i].clear();
            ans[i] = -1;
        }
        uniq.clear();
        for(int i=0;i<n;i++){
            cin >> arr[i];
            if(v[arr[i]].size()==0){uniq.push_back(arr[i]);}
            v[arr[i]].push_back(i);
        }
        sort(uniq.begin(),uniq.end());
        for(int i=0;i< uniq.size();i++){
            int k = -2;
            int last = -1;
            for(int j=0;j<v[uniq[i]].size();j++){
                k = max(k,v[uniq[i]][j]-last);
                last = v[uniq[i]][j];
            }
             k= max(k,n-last);
            for(int ii=k;ii<=n;ii++){
                if(ans[ii]==-1){
                    ans[ii] = uniq[i];
                }
                else break;
            }

        }

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

    return 0;
}