#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ms(v,x) memset(v,x,sizeof(v))
using namespace std;

const ll INF=1ll<<60;
const ll modulo=998244353;
const double PI=acos(-1);

ll binpow(ll a, ll b) {
	if (b == 0)
		return 1;
	ll res = binpow(a, b / 2);
	if (b % 2)
		return res * res * a;
	else
		return res * res;
}

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	// freopen("lcm.in", "r", stdin);
	// freopen("hidden.out", "w", stdout);
	ll t=1;
	cin>>t;
	while(t--){
		ll n,m,i,j,resp=INF;
		cin>>n;
		vector<ll> vet;
		map<ll,ll> mapa;
		cin>>m;
		vet.pb(m);
		for(i=1;i<n;i++){
			cin>>m;
			if(vet[vet.size()-1]!=m) {
				vet.pb(m);
				mapa[m]++;
			}
		}
		for(i=0;i<vet.size();i++){
			resp=min(resp,mapa[vet[i]]+(vet[vet.size()-1]==vet[i] ? 0: 1));
		}
		cout<<resp<<endl;
	}
}