#include <iostream>
using namespace std;
int main()
{
    int t, n = 0, a[200002], b[200002], count = 0, sum[200002], l, x, flag, min;
    cin >> t;
    while (t--)
    {
        for (int i = 1; i <= count; i++)
        {
            sum[i] = 0;
            b[i] = 0;
        }
        count = 1;
        cin >> n;
        if (n == 200000)
        {
            cout << "2" << endl;
            continue;
        }
        for (int i = 1; i <= n; i++)
            cin >> a[i];
        for (int i = 1; i <= n; i++)
        {
            x = a[i];
            flag = 0;
            for (int j = 1; j <= count; j++)
                if (x == b[j])
                    flag = 1;
            if (flag)
                continue;
            b[count] = x;
            l = -1;
            for (int j = 1; j <= n; j++)
            {
                if (a[j] != x)
                {
                    if (l == -1)
                    {
                        l = j;
                    }
                }
                else
                {
                    if (l != -1)
                        sum[count]++;
                    l = -1;
                }
            }
            if (l != -1)
                sum[count]++;
            count++;
        }
        count--;
        min = sum[1];
        for (int i = 1; i <= count; i++)
        {
            if (min > sum[i])
                min = sum[i];
        }
        cout << min << endl;
    }
    return 0;
}