#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
typedef long long ll;
const ll maxn=2e5+5;
ll tc,n,a[maxn],f[maxn],x;
int main(){
    ios_base::sync_with_stdio(0);
    cin>>tc;
    while(tc--){
        cin>>n;
        rep(i,0,n) cin>>a[i];
        ll m=unique(a,a+n)-a;
        fill(f+1,f+1+n,0ll);
        rep(i,0,m) f[a[i]]++;
        f[a[0]]--; f[a[m-1]]--;
        ll ans=1e9;
        rep(i,0,m) ans=min(f[a[i]],ans);
        cout<<ans+1<<'\n';
    }
}