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

const int MAXN = 2*1e5 + 10;
int t , n , ans = 1e9 , a [MAXN] , res [MAXN];

int main() {
    
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin >> t;
    for (int i = 0 ; i < t ; i++) {
    	cin >> n;
    	for (int i = 1 ; i <= n ; i++) {
    		cin >> a[i];
			if (a[i-1] != a[i]) {
    			res [a[i]] ++;
			}
		}
		for (int i = 1 ; i <= n ; i++) {
			if (res [i] != 0) {
				if (a[1] == i) {
					res [i] --;
				}
				if (a [n] == i) {
					res [i] --;
				}
				ans = min (res [i] , ans);
			}	
		}
		for (int i = 1 ; i <= n ; i++) {
			res [i] = 0;
		}
		cout << ans+1 << "\n";
		ans = 1e9;
	}
    
    return 0;
}
