#include <bits/stdc++.h>

using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        vector<int> v;
        map<int, pair<vector<int>,int>> used;
        for(int i = 0;i<n;i++)
        {
            int x;
            cin>>x;
            v.push_back(x);
            if(used.find(x)==used.end())
                used.insert({x,{{i},i!=0}});
            else{
                used[x].first.push_back(i);
                if(used[x].first[used[x].first.size()-2]!=i-1)
                    used[x].second++;
            }
        }
        int minimum = 21321;
        for(auto& i:used)
        {
            if(i.second.first[i.second.first.size()-1]!=n-1)
                i.second.second++;
            minimum = min(i.second.second,minimum);
        }
        cout<<minimum<<'\n';
    }
    return 0;
}
