#include <bits/stdc++.h>
using namespace std;
int findMode(const vector<int>& nums, int i) {
unordered_map<int, int> freq;
for (int num = 0; num<=i; num++) {
freq[num]++;
}
int mode = nums[0];
int maxCount = 0;
for (const auto& pair : freq) {
if (pair.second > maxCount) {
maxCount = pair.second;
mode = pair.first;
}
}
return mode;
}
int main() {
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int arr[n];
vector<int> sequence;
for(int i=0; i<n; i++)
{
int a;
cin>>a;
sequence.push_back(a);
}
// brute force
int b[n];
for(int i=0; i<n; i++)
{
b[i]=findMode(sequence,i);
cout<<b[i]<<" ";
}
cout<<endl;
}
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgZmluZE1vZGUoY29uc3QgdmVjdG9yPGludD4mIG51bXMsIGludCBpKSB7CiAgICB1bm9yZGVyZWRfbWFwPGludCwgaW50PiBmcmVxOwogICAgZm9yIChpbnQgbnVtID0gMDsgbnVtPD1pOyBudW0rKykgewogICAgICAgIGZyZXFbbnVtXSsrOwogICAgfQogICAgaW50IG1vZGUgPSBudW1zWzBdOwogICAgaW50IG1heENvdW50ID0gMDsKICAgIGZvciAoY29uc3QgYXV0byYgcGFpciA6IGZyZXEpIHsKICAgICAgICBpZiAocGFpci5zZWNvbmQgPiBtYXhDb3VudCkgewogICAgICAgICAgICBtYXhDb3VudCA9IHBhaXIuc2Vjb25kOwogICAgICAgICAgICBtb2RlID0gcGFpci5maXJzdDsKICAgICAgICB9CiAgICB9CgogICAgcmV0dXJuIG1vZGU7Cn0KCmludCBtYWluKCkgewoJaW50IHQ7CiAgICBjaW4+PnQ7CiAgICB3aGlsZSh0LS0pCiAgICB7CiAgICAgICAgaW50IG47CiAgICAgICAgY2luPj5uOwogICAgICAgIGludCBhcnJbbl07CiAgICAgICAgdmVjdG9yPGludD4gc2VxdWVuY2U7CiAgICAgICAgZm9yKGludCBpPTA7IGk8bjsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgaW50IGE7CiAgICAgICAgICAgIGNpbj4+YTsKICAgICAgICAgICAgc2VxdWVuY2UucHVzaF9iYWNrKGEpOwogICAgICAgIH0KICAgICAgICAvLyBicnV0ZSBmb3JjZQogICAgICAgIGludCBiW25dOwogICAgICAgIGZvcihpbnQgaT0wOyBpPG47IGkrKykKICAgICAgICB7CiAgICAgICAgICAgIGJbaV09ZmluZE1vZGUoc2VxdWVuY2UsaSk7CiAgICAgICAgICAgIGNvdXQ8PGJbaV08PCIgIjsKICAgICAgICB9CiAgICAgICAgY291dDw8ZW5kbDsKICAgIH0KfQo=