#include <iostream>
using namespace std;

long long int *a;
long long int *b;
unsigned long long int mn;

int main() {
	long long int t;
	cin >> t;

	for (long long int z = 0; z < t; z++) {
		long long int n;
		cin >> n;
		a = new long long int[n];
		b = new long long int[n];
		for (long long int i = 0; i < n; i++) {
			cin >> a[i];
			b[i] = -1;
		}
		for (long long int i = 0; i < n; i++) {
			if (b[a[i]-1] == -1)
				if (i == 0) b[a[i]-1] = 0;
				else b[a[i]-1] = 1;
		}

		mn = -1;
		for (long long int i = 0; i < n-1; i++) {
			if (a[i] != a[i+1]) b[a[i]-1]++;
		}
		for (long long int i = 0; i < n; i++) {
			if (b[a[i]-1] < mn) mn = b[a[i]-1];
		}

		cout << mn << endl;
		

		delete[] a;
		delete[] b;
	}

	return 0;
}
