#include <iostream>
#include <iomanip>
#include <stack>
#include <vector>
#include <map>
#include <queue>
#include <math.h>
#include <iomanip>
#include <set>
#include <string>
#include <stdlib.h>
#include <time.h> 
#include <algorithm>
#define ll long long
#define ui unsigned int
#define ld long double
#define p(x,y) make_pair(x, y)
#define TASK "railroad"
using namespace std;
const ll MAXN = 200001;
const double eps = 1e-8;
void fastIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
}

int main()
{
	fastIO();
	int t = 0, n, a, b;
	cin >> t;
	for (int i = 0; i < t; i++)
	{
		cin >> n;
		map <int, int> how;
		set <int> was;
		int last, now, ansh;
		cin >> last;
		was.insert(last);
		for (int j = 1; j < n; j++)
		{
			cin >> now;
			if (now == last)
				continue;
			was.insert(now);
			last = now;
			how[now]++;
		}
		how[now]--;
		ansh = how[now] + 1;
		for (auto it = was.begin(); it != was.end(); it++)
			ansh = min(ansh, how[*it] + 1);
		cout << ansh << endl;
	}
	return 0;
}