/**
 * author:BYTX
 *
 * */
#include <bits/stdc++.h>
#include <algorithm>
#define int long long
#define Test cout << "this is a test line" << endl
#define debug(x) cout << #x << '\t' << x << endl
#define skip " "
using namespace std;
const int INF = 1e9;
void solve()
{
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++)
        cin >> v[i];
    if (count(v.begin(), v.end(), v[0]) == n)
    {
        cout << 1 << endl;
        for (int i = 0; i < n; ++i)
            cout << 1 << " ";
        cout << endl;
        return;
    }
    if (n % 2 == 0)
    {
        cout << 2 << endl;
        for (int i = 0; i < n; i++)
            cout << i % 2 + 1 << " ";
        cout << endl;
        return ;
    }
    for (int i = 0; i < n; i++)
    {
        if (v[i] == v[(i + 1) % n])
        {
            cout << 2 << endl;
            for (int j = 0; j < i + 1; j++)
                cout << (j % 2) + 1 << " ";
            cout << (i % 2) + 1 << " ";
            for (int j = i + 2; j < n; j++)
                cout << (j + 1) % 2 + 1 << " ";
            cout << endl;
            return;
        }
    }
    cout << 3 << endl;
	for (int i = 0; i < n - 1; ++i) {
		cout << i % 2 + 1 << " ";
	}
	cout << 3 << endl;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
        solve();

    // system("pause");
    return 0;
}


/**
 * author:BYTX
 *
 * */
#include <bits/stdc++.h>
#include <algorithm>
// #define int long long
#define Test cout << "this is a test line" << endl
#define debug(x) cout << #x << '\t' << x << endl
#define skip " "
using namespace std;
const int INF = 1e9;
int solve() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	if (count(a.begin(), a.end(), a[0]) == n) {
		cout << 1 << endl;
		for (int i = 0; i < n; ++i) {
			cout << 1 << " ";
		}
		cout << endl;
		return 0;
	}

	if (n % 2 == 0) {
		cout << 2 << endl;
		for (int i = 0; i < n; ++i) {
			cout << i % 2 + 1 << " ";
		}
		cout << endl;
		return 0;
	}

	for (int i = 0; i < n; ++i) {
		if (a[i] == a[(i + 1) % n]) {
			vector<int> ans(n);
			for (int j = 0, pos = i + 1; pos < n; ++pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			for (int j = 0, pos = i; pos >= 0; --pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			cout << 2 << endl;
			for (int pos = 0; pos < n; ++pos) {
				cout << ans[pos] << " ";
			}
			cout << endl;
			return 0;
		}
	}

	cout << 3 << endl;
	for (int i = 0; i < n - 1; ++i) {
		cout << i % 2 + 1 << " ";
	}
	cout << 3 << endl;
    return 0;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
        solve();

    // system("pause");
    return 0;
}


/**
 * author:BYTX
 *
 * */
#include <bits/stdc++.h>
#include <algorithm>
#define int long long
#define Test cout << "this is a test line" << endl
#define debug(x) cout << #x << '\t' << x << endl
#define skip " "
using namespace std;
const int INF = 1e9;
int solve()
{
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++)
        cin >> v[i];
    if (count(v.begin(), v.end(), v[0]) == n)
    {
        cout << 1 << endl;
        for (int i = 0; i < n; ++i)
            cout << 1 << " ";
        cout << endl;
        return 0;
    }
    if (n % 2 == 0)
    {
        cout << 2 << endl;
        for (int i = 0; i < n; i++)
            cout << i % 2 + 1 << " ";
        cout << endl;
        return 0;
    }
    for (int i = 0; i < n; i++)
    {
        if (v[i] == v[(i + 1) % n])
        {
            cout << 2 << endl;
            for (int j = 0; j < i + 1; j++)
                cout << (j % 2) + 1 << " ";
            cout << (i % 2) + 1 << " ";
            for (int j = i + 2; j < n; j++)
                cout << (j + 1) % 2 + 1 << " ";
            cout << endl;
            return 0;
        }
    }
    cout << 3 << endl;
	for (int i = 0; i < n - 1; ++i) {
		cout << i % 2 + 1 << " ";
	}
	cout << 3 << endl;
    return 0;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
        solve();

    // system("pause");
    return 0;
}


/**
 * author:BYTX
 *
 * */
#include <bits/stdc++.h>
#include <algorithm>
// #define int long long
#define Test cout << "this is a test line" << endl
#define debug(x) cout << #x << '\t' << x << endl
#define skip " "
using namespace std;
const int INF = 1e9;
int solve1()
{
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++)
        cin >> v[i];
    if (count(v.begin(), v.end(), v[0]) == n)
    {
        cout << 1 << endl;
        for (int i = 0; i < n; ++i)
            cout << 1 << " ";
        cout << endl;
        return 0;
    }
    if (n % 2 == 0)
    {
        cout << 2 << endl;
        for (int i = 0; i < n; i++)
            cout << i % 2 + 1 << " ";
        cout << endl;
        return 0;
    }
    for (int i = 0; i < n; ++i) {
		if (v[i] == v[(i + 1) % n]) {
			vector<int> ans(n);
			for (int j = 0, pos = i + 1; pos < n; ++pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			for (int j = 0, pos = i; pos >= 0; --pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			cout << 2 << endl;
			for (int pos = 0; pos < n; ++pos) {
				cout << ans[pos] << " ";
			}
			cout << endl;
			return 0;
		}
	}
    cout << 3 << endl;
	for (int i = 0; i < n - 1; ++i) {
		cout << i % 2 + 1 << " ";
	}
	cout << 3 << endl;
    return 0;
}
int solve() {
	int n;
    cin >> n;
    vector<int> a;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    if (count(a.begin(), a.end(), a[0]) == n)
    {
        cout << 1 << endl;
        for (int i = 0; i < n; ++i)
            cout << 1 << " ";
        cout << endl;
        return 0;
    }

	if (n % 2 == 0) {
		cout << 2 << endl;
		for (int i = 0; i < n; ++i) {
			cout << i % 2 + 1 << " ";
		}
		cout << endl;
		return 0;
	}

	for (int i = 0; i < n; ++i) {
		if (a[i] == a[(i + 1) % n]) {
			vector<int> ans(n);
			for (int j = 0, pos = i + 1; pos < n; ++pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			for (int j = 0, pos = i; pos >= 0; --pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			cout << 2 << endl;
			for (int pos = 0; pos < n; ++pos) {
				cout << ans[pos] << " ";
			}
			cout << endl;
			return 0;
		}
	}

	cout << 3 << endl;
	for (int i = 0; i < n - 1; ++i) {
		cout << i % 2 + 1 << " ";
	}
	cout << 3 << endl;
    return 0;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
        solve();

    // system("pause");
    return 0;
}


/**
 * author:BYTX
 *
 * */
#include <bits/stdc++.h>
#include <algorithm>
// #define int long long
#define Test cout << "this is a test line" << endl
#define debug(x) cout << #x << '\t' << x << endl
#define skip " "
using namespace std;
const int INF = 1e9;
int solve1()
{
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++)
        cin >> v[i];
    if (count(v.begin(), v.end(), v[0]) == n)
    {
        cout << 1 << endl;
        for (int i = 0; i < n; ++i)
            cout << 1 << " ";
        cout << endl;
        return 0;
    }
    if (n % 2 == 0)
    {
        cout << 2 << endl;
        for (int i = 0; i < n; i++)
            cout << i % 2 + 1 << " ";
        cout << endl;
        return 0;
    }
    for (int i = 0; i < n; ++i) {
		if (v[i] == v[(i + 1) % n]) {
			vector<int> ans(n);
			for (int j = 0, pos = i + 1; pos < n; ++pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			for (int j = 0, pos = i; pos >= 0; --pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			cout << 2 << endl;
			for (int pos = 0; pos < n; ++pos) {
				cout << ans[pos] << " ";
			}
			cout << endl;
			return 0;
		}
	}
    cout << 3 << endl;
	for (int i = 0; i < n - 1; ++i) {
		cout << i % 2 + 1 << " ";
	}
	cout << 3 << endl;
    return 0;
}
int solve() {
	int n;
    cin >> n;
    vector<int> a;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    if (count(a.begin(), a.end(), a[0]) == n) {
		cout << 1 << endl;
		for (int i = 0; i < n; ++i) {
			cout << 1 << " ";
		}
		cout << endl;
		return 0;
	}

	if (n % 2 == 0) {
		cout << 2 << endl;
		for (int i = 0; i < n; ++i) {
			cout << i % 2 + 1 << " ";
		}
		cout << endl;
		return 0;
	}

	for (int i = 0; i < n; ++i) {
		if (a[i] == a[(i + 1) % n]) {
			vector<int> ans(n);
			for (int j = 0, pos = i + 1; pos < n; ++pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			for (int j = 0, pos = i; pos >= 0; --pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			cout << 2 << endl;
			for (int pos = 0; pos < n; ++pos) {
				cout << ans[pos] << " ";
			}
			cout << endl;
			return 0;
		}
	}

	cout << 3 << endl;
	for (int i = 0; i < n - 1; ++i) {
		cout << i % 2 + 1 << " ";
	}
	cout << 3 << endl;
    return 0;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
        solve();

    // system("pause");
    return 0;
}


/**
 * author:BYTX
 *
 * */
#include <bits/stdc++.h>
#include <algorithm>
// #define int long long
#define Test cout << "this is a test line" << endl
#define debug(x) cout << #x << '\t' << x << endl
#define skip " "
using namespace std;
const int INF = 1e9;
int solve1()
{
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++)
        cin >> v[i];
    if (count(v.begin(), v.end(), v[0]) == n)
    {
        cout << 1 << endl;
        for (int i = 0; i < n; ++i)
            cout << 1 << " ";
        cout << endl;
        return 0;
    }
    if (n % 2 == 0)
    {
        cout << 2 << endl;
        for (int i = 0; i < n; i++)
            cout << i % 2 + 1 << " ";
        cout << endl;
        return 0;
    }
    for (int i = 0; i < n; ++i) {
		if (v[i] == v[(i + 1) % n]) {
			vector<int> ans(n);
			for (int j = 0, pos = i + 1; pos < n; ++pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			for (int j = 0, pos = i; pos >= 0; --pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			cout << 2 << endl;
			for (int pos = 0; pos < n; ++pos) {
				cout << ans[pos] << " ";
			}
			cout << endl;
			return 0;
		}
	}
    cout << 3 << endl;
	for (int i = 0; i < n - 1; ++i) {
		cout << i % 2 + 1 << " ";
	}
	cout << 3 << endl;
    return 0;
}
int solve() {
	int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n; i++)
        cin >> v[i];
    if (count(v.begin(), v.end(), v[0]) == n)
    {
        cout << 1 << endl;
        for (int i = 0; i < n; ++i)
            cout << 1 << " ";
        cout << endl;
        return 0;
    }
    if (n % 2 == 0)
    {
        cout << 2 << endl;
        for (int i = 0; i < n; i++)
            cout << i % 2 + 1 << " ";
        cout << endl;
        return 0;
    }

	for (int i = 0; i < n; ++i) {
		if (v[i] == v[(i + 1) % n]) {
			vector<int> ans(n);
			for (int j = 0, pos = i + 1; pos < n; ++pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			for (int j = 0, pos = i; pos >= 0; --pos, j ^= 1) {
				ans[pos] = j + 1;
			}
			cout << 2 << endl;
			for (int pos = 0; pos < n; ++pos) {
				cout << ans[pos] << " ";
			}
			cout << endl;
			return 0;
		}
	}

	cout << 3 << endl;
	for (int i = 0; i < n - 1; ++i) {
		cout << i % 2 + 1 << " ";
	}
	cout << 3 << endl;
    return 0;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
        solve();

    // system("pause");
    return 0;
}


/*
	ID: sixathofpain
	TASK: carausel
	LANG: C++

*/

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;

   	int q;
   	cin>>q;
   	while(q--){
   		int n;
   		cin>>n;
   		int arr[n+2];
   		arr[0]=-1;
   		arr[n]= -1;
   		int ok=0;
   		set<int> st;
   		for(int i=0;i<n;i++){
   			cin>>arr[i];
   			st.insert(arr[i]);
   		}
   		if(st.size()==1){
   			cout<<1<<endl;
   			for(int i=0;i<n;i++)
   				cout<<1<<" ";
   			cout<<endl;
   			continue;
   		}
   		int ans[n]={0};
   		if(n%2==0){
   			cout<<2<<endl;
   			for(int i = 0;i<n;i++){
   				cout<<i%2+1<<" ";
   			}
   			cout<<endl;
   			continue;
   		}
   		for(int i=0;i<n;i++){
   			if(arr[i]==arr[(i+1)%n]){

   				ans[i] = ans[(i+1)%n] = 1;
   				ok = i;
   				break;
   			}
   		}
   		if(ok){
   			for(int j = ok+2,t=0;j<n;j++,t=!t){
   				ans[j] = t;
   			}
   			for(int j=ok-1,t=0;j>=0;j--,t=!t){
   				ans[j]=t;
   			}
   			cout<<"2"<<endl;
   			for(int i=0;i<n;i++)
   				cout<<ans[i]+1<<" ";
   			cout<<endl;
   		}
   		else{
   			cout<<3<<endl;
   			for(int i=0;i<n;i++){
   				cout<<i%3+1<<" ";
   			}
   			cout<<endl;
   		}
   	}

    return 0;
}


/*
	ID: sixathofpain
	TASK: carausel
	LANG: C++

*/

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;

   	int q;
   	cin>>q;
   	while(q--){
   		int n;
   		cin>>n;
   		int arr[n+2];
   		arr[0]=-1;
   		arr[n]= -1;
   		int ok=0;
   		set<int> st;
   		for(int i=0;i<n;i++){
   			cin>>arr[i];
   			st.insert(arr[i]);
   		}
   		if(st.size()==1){
   			cout<<1<<endl;
   			for(int i=0;i<n;i++)
   				cout<<1<<" ";
   			cout<<endl;
   			continue;
   		}
   		int ans[n]={0};
   		if(n%2==0){
   			cout<<2<<endl;
   			for(int i = 0;i<n;i++){
   				cout<<i%2+1<<" ";
   			}
   			cout<<endl;
   			continue;
   		}
   		for(int i=0;i<n;i++){
   			if(arr[i]==arr[(i+1)%n]){

   				ans[i] = ans[(i+1)%n] = 1;
   				ok = i;
   				break;
   			}
   		}
   		if(ok){
   			for(int j = ok+2,t=0;j<n;j++,t=!t){
   				ans[j] = t;
   			}
   			for(int j=ok-1,t=0;j>=0;j--,t=!t){
   				ans[j]=t;
   			}
   			cout<<"2"<<endl;
   			for(int i=0;i<n;i++)
   				cout<<ans[i]+1<<" ";
   			cout<<endl;
   		}
   		else{
   			cout<<3<<endl;
   			for(int i=0;i<n-1;i++){
   				cout<<i%2+1<<" ";
   			}
   			cout<<3<<" ";
   			cout<<endl;
   		}
   	}

    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    int tc;
    cin>>tc;
    while(tc--){
    	int n;
    	cin>>n;
    	int arr[n];
    	for(int i =0;i<n;i++){
    		cin>>arr[i];
    	}
    	//case 1
    	int f=0;
    	for(int i =0;i<n;i++){
    		if(arr[i]!=arr[(i+1)%n])
    			f=1;
    	}
    	if(!f)
    	{
    		cout<<1<<endl;
    		for(int i=0;i<n;i++)
    			cout<<1<<" ";
    		cout<<endl;
    		continue;
    	}
    	// int ans=2;
    	// for(int i=0;i<n;i++){
    	// 	int p = i-1+n;p%=n;
    	// 	int q = i+1;q%=n;
    	// 	if(arr[p]!=arr[q] and arr[p]!=arr[i] and arr[q]!=arr[i]){
    	// 		ans=3;
    	// 		break;
    	// 	}
    	// }
    	int col[n];
    	int c = 0;
    	int ans = 2;
    	col[0]=c;
    	for(int i=1;i<n;i++){
    		if(arr[i]!=arr[i-1]){
    			col[i] = (col[i-1]+1)%ans;
    		}
    		else{
    			col[i]= col[i-1];
    		}
    	}

    	if(arr[0]!=arr[n-1] and col[0]==col[n-1]){
    		set<int> st;
    		st.insert(col[0]);
    		st.insert(col[n-2]);
    		for(int i=0;i<=2;i++){
    			if(st.count(i)==0){
    				ans++;
    				col[n-1]=i;
    				break;
    			}
    		}
    	}

    	cout<<ans<<endl;
    	for(int i=0;i<n;i++){
    		cout<<col[i]+1<<" ";
    	}
    	cout<<endl;

    }

    return 0;
}


/*
	ID: sixathofpain
	TASK: carausel
	LANG: C++

*/

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;

   	int q;
   	cin>>q;
   	while(q--){
   		int n;
   		cin>>n;
   		int arr[n+2];
   		arr[0]=-1;
   		arr[n]= -1;
   		int ok=-1;
   		set<int> st;
   		for(int i=0;i<n;i++){
   			cin>>arr[i];
   			st.insert(arr[i]);
   		}
   		if(st.size()==1){
   			cout<<1<<endl;
   			for(int i=0;i<n;i++)
   				cout<<1<<" ";
   			cout<<endl;
   			continue;
   		}
   		int ans[n]={0};
   		if(n%2==0){
   			cout<<2<<endl;
   			for(int i = 0;i<n;i++){
   				cout<<i%2+1<<" ";
   			}
   			cout<<endl;
   			continue;
   		}
   		for(int i=0;i<n;i++){
   			if(arr[i]==arr[(i+1)%n]){
   				ans[i] = ans[(i+1)%n] = 1;
   				ok = i;
   				break;
   			}
   		}
   		if(ok>=0){
   			for(int j = ok+2,t=0;j<n;j++,t=!t){
   				ans[j] = t;
   			}
   			for(int j=ok-1,t=0;j>=0;j--,t=!t){
   				ans[j]=t;
   			}
   			cout<<"2"<<endl;
   			for(int i=0;i<n;i++)
   				cout<<ans[i]+1<<" ";
   			cout<<endl;
   		}
   		else{
   			cout<<3<<endl;
   			for(int i=0;i<n-1;i++){
   				cout<<i%2+1<<" ";
   			}
   			cout<<3<<" ";
   			cout<<endl;
   		}
   	}

    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    int tc;
    cin>>tc;
    while(tc--){
    	int n;
    	cin>>n;
    	int arr[n];
    	for(int i =0;i<n;i++){
    		cin>>arr[i];
    	}
    	//case 1
    	int f=0;
    	for(int i =0;i<n;i++){
    		if(arr[i]!=arr[(i+1)%n])
    			f=1;
    	}
    	if(!f)
    	{
    		cout<<1<<endl;
    		for(int i=0;i<n;i++)
    			cout<<1<<" ";
    		cout<<endl;
    		continue;
    	}
    	int ans=2;
    	for(int i =0;i<n;i++){
    		int p = i-1+n;p%=n;
    		int q = i+1;q%=n;
    		if(arr[p]!=arr[q] and arr[p]!=arr[i] and arr[q]!=arr[i]){
    			ans=3;
    			break;
    		}
    	}

    	int col[n];
    	int c = 0;
    	col[0]=c;
    	for(int i=1;i<n;i++){
    		if(arr[i]!=arr[i-1]){
    			col[i] = (c+1)%ans;
    			c=(c+1)%ans;
    		}
    		else
    			col[i]= c%ans;
    	}
    	if(arr[0]==arr[n-1] and col[0]==col[n-1]){
    		set<int> st;
    		st.insert(col[0]);
    		st.insert(col[n-2]);
    		for(int i=0;i<=2;i++){
    			if(st.count(i)==0){
    				col[n-1]=i;
    				break;
    			}
    		}
    	}
    	cout<<ans<<endl;
    	for(int i=0;i<n;i++){
    		cout<<col[i]+1<<" ";
    	}
    	cout<<endl;

    }

    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    int tc;
    cin>>tc;
    while(tc--){
    	int n;
    	cin>>n;
    	int arr[n];
    	for(int i =0;i<n;i++){
    		cin>>arr[i];
    	}
    	//case 1
    	int f=0;
    	for(int i =0;i<n;i++){
    		if(arr[i]!=arr[(i+1)%n])
    			f=1;
    	}
    	if(!f)
    	{
    		cout<<1<<endl;
    		for(int i=0;i<n;i++)
    			cout<<1<<" ";
    		cout<<endl;
    		continue;
    	}

    	int col[n]={0};
    	int ans=2;
    	for (int i = 0; i < n; ++i)
    	{
    		/* code */
    		if(arr[i]!=arr[i-1])
    			col[i]=!col[i-1];
    	}

    	if(arr[0]!=arr[n-1] and col[0]==col[n-1]){
    		col[n-1]=!col[n-1];
    		if(arr[n-1]!=arr[n-2] and col[n-2]==col[n-1]){
    			ans++;
    			col[n-1]=2;
    		}
    	}

    	cout<<ans<<endl;
    	for(int i=0;i<n;i++){
    		cout<<col[i]+1<<" ";
    	}
    	cout<<endl;

    }

    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    int tc;
    cin>>tc;
    while(tc--){
    	int n;
    	cin>>n;
    	int arr[n];
    	for(int i =0;i<n;i++){
    		cin>>arr[i];
    	}
    	//case 1
    	int f=0;
    	for(int i =0;i<n;i++){
    		if(arr[i]!=arr[(i+1)%n])
    			f=1;
    	}
    	if(!f)
    	{
    		cout<<1<<endl;
    		for(int i=0;i<n;i++)
    			cout<<1<<" ";
    		cout<<endl;
    		continue;
    	}

    	int col[n];
    	int c = 0;
    	int ans = 2;
    	col[0]=c;
    	for(int i=1;i<n;i++){
    		if(arr[i]!=arr[i-1]){
    			col[i] = (col[i-1]+1)%ans;
    		}
    		else{
    			col[i]= col[i-1];
    		}
    	}

    	if(arr[0]!=arr[n-1] and col[0]==col[n-1]){
    		set<int> st;
    		st.insert(col[0]);
    		st.insert(col[n-2]);
    		for(int i=0;i<=2;i++){
    			if(st.count(i)==0){
    				if(st.size()==2)
    					ans++;
    				col[n-1]=i;
    				break;
    			}
    		}
    	}

    	cout<<ans<<endl;
    	for(int i=0;i<n;i++){
    		cout<<col[i]+1<<" ";
    	}
    	cout<<endl;

    }

    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    int tc;
    cin>>tc;
    while(tc--){
    	int n;
    	cin>>n;
    	int arr[n];
    	for(int i =0;i<n;i++){
    		cin>>arr[i];
    	}
    	//case 1
    	int f=0;
    	for(int i =0;i<n;i++){
    		if(arr[i]!=arr[(i+1)%n])
    			f=1;
    	}
    	if(!f)
    	{
    		cout<<1<<endl;
    		for(int i=0;i<n;i++)
    			cout<<1<<" ";
    		cout<<endl;
    		continue;
    	}
    	int ans=2;
    	for(int i=0;i<n;i++){
    		int p = i-1+n;p%=n;
    		int q = i+1;q%=n;
    		if(arr[p]!=arr[q] and arr[p]!=arr[i] and arr[q]!=arr[i]){
    			ans=3;
    			break;
    		}
    	}

    	int col[n];
    	int c = 0;
    	col[0]=c;
    	for(int i=1;i<n;i++){
    		if(arr[i]!=arr[i-1]){
    			col[i] = (c+1)%ans;
    			c=(c+1)%ans;
    		}
    		else
    			col[i]= c%ans;
    	}
    	if(arr[0]!=arr[n-1] and col[0]==col[n-1]){
    		set<int> st;
    		st.insert(col[0]);
    		st.insert(col[n-2]);
    		for(int i=0;i<=2;i++){
    			if(st.count(i)==0){
    				col[n-1]=i;
    				break;
    			}
    		}
    	}
    	cout<<ans<<endl;
    	for(int i=0;i<n;i++){
    		cout<<col[i]+1<<" ";
    	}
    	cout<<endl;

    }

    return 0;
}


/*
	ID: sixathofpain
	TASK: carausel
	LANG: C++

*/

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;

   	int q;
   	cin>>q;
   	while(q--){
   		int n;
   		cin>>n;
   		int arr[n+2];
   		arr[0]=-1;
   		arr[n]= -1;
   		int ok=0;
   		set<int> st;
   		for(int i=0;i<n;i++){
   			cin>>arr[i];
   			st.insert(arr[i]);
   		}
   		if(st.size()==n){
   			cout<<1<<endl;
   			for(int i=0;i<n;i++)
   				cout<<1<<" ";
   			cout<<endl;
   			continue;
   		}
   		int ans[n]={0};
   		if(n%2==0){
   			cout<<2<<endl;
   			for(int i = 0;i<n;i++){
   				cout<<i%2+1<<" ";
   			}
   			cout<<endl;
   			continue;
   		}
   		for(int i=0;i<n;i++){
   			if(arr[i]==arr[(i+1)%n]){

   				ans[i] = ans[(i+1)%n] = 1;
   				ok = i;
   				break;
   			}
   		}
   		if(ok){
   			for(int j = ok+2,t=0;j<n;j++,t=!t){
   				ans[j] = t;
   			}
   			for(int j=ok-1,t=0;j>=0;j--,t=!t){
   				ans[j]=t;
   			}
   			cout<<"2"<<endl;
   			for(int i=0;i<n;i++)
   				cout<<ans[i]+1<<" ";
   			cout<<endl;
   		}
   		else{
   			cout<<3<<endl;
   			for(int i=0;i<n;i++){
   				cout<<i%3+1<<" ";
   			}
   			cout<<endl;
   		}
   	}

    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    int tc;
    cin>>tc;
    while(tc--){
    	int n;
    	cin>>n;
    	int arr[n];
    	for(int i =0;i<n;i++){
    		cin>>arr[i];
    	}
    	//case 1
    	int f=0;
    	for(int i =0;i<n;i++){
    		if(arr[i]!=arr[(i+1)%n])
    			f=1;
    	}
    	if(!f)
    	{
    		cout<<1<<endl;
    		for(int i=0;i<n;i++)
    			cout<<1<<" ";
    		cout<<endl;
    		continue;
    	}

    	int col[n]={0};
    	int ans=2;
    	for (int i = 0; i < n; ++i)
    	{
    		/* code */
    		if(arr[i]!=arr[i-1])
    			col[i]=!col[i-1];
    	}

    	if(arr[0]!=arr[n-1] and col[0]==col[n-1]){
    		ans++;
    		col[n-1]=2;
    	}

    	cout<<ans<<endl;
    	for(int i=0;i<n;i++){
    		cout<<col[i]+1<<" ";
    	}
    	cout<<endl;

    }

    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    int tc;
    cin>>tc;
    while(tc--){
    	int n;
    	cin>>n;
    	int arr[n];
    	for(int i =0;i<n;i++){
    		cin>>arr[i];
    	}

    	int f=0;
    	for(int i =0;i<n;i++){
    		if(arr[i]!=arr[(i+1)%n])
    			f=1;
    	}
    	if(!f)
    	{
    		cout<<1<<endl;
    		for(int i=0;i<n;i++)
    			cout<<1<<" ";
    		cout<<endl;
    		continue;
    	}

    	int col[n]={0};
    	int ans=2;
    	for (int i = 1; i < n; ++i)
    	{
    		if(arr[i]!=arr[i-1])
    			col[i]=!col[i-1];
    		else
    			col[i]=col[i-1];
    	}

    	if(arr[0]!=arr[n-1] and col[0]==col[n-1]){
    		col[n-1]=!col[n-1];
    		if(arr[n-1]!=arr[n-2] and col[n-2]==col[n-1]){
    			ans++;
    			col[n-1]=2;
    		}
    	}

    	cout<<ans<<endl;
    	for(int i=0;i<n;i++){
    		cout<<col[i]+1<<" ";
    	}
    	cout<<endl;

    }

    return 0;
}


/*
	ID: sixathofpain
	TASK: carausel
	LANG: C++

*/

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;

   	int q;
   	cin>>q;
   	while(q--){
   		int n;
   		cin>>n;
   		int arr[n+2];
   		arr[0]=-1;
   		arr[n]= -1;
   		int ok=0;
   		for(int i=0;i<n;i++)
   			cin>>arr[i];
   		int ans[n]={0};
   		if(n%2==0){
   			cout<<2<<endl;
   			for(int i = 0;i<n;i++){
   				cout<<i%2+1<<" ";
   			}
   			cout<<endl;
   			continue;
   		}
   		for(int i=0;i<n;i++){
   			if(arr[i]==arr[(i+1)%n]){

   				ans[i] = ans[(i+1)%n] = 1;
   				ok = i;
   				break;
   			}
   		}
   		if(ok){
   			for(int j = ok+2,t=0;j<n;j++,t=!t){
   				ans[j] = t;
   			}
   			for(int j=ok-1,t=0;j>=0;j--,t=!t){
   				ans[j]=t;
   			}
   			cout<<"2"<<endl;
   			for(int i=0;i<n;i++)
   				cout<<ans[i]+1<<" ";
   			cout<<endl;
   		}
   		else{
   			cout<<3<<endl;
   			for(int i=0;i<n;i++){
   				cout<<n%3+1<<" ";
   			}
   			cout<<endl;
   		}
   	}

    return 0;
}


/*
	ID: sixathofpain
	TASK: carausel
	LANG: C++

*/

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;

   	int q;
   	cin>>q;
   	while(q--){
   		int n;
   		cin>>n;
   		int arr[n+2];
   		arr[0]=-1;
   		arr[n]= -1;
   		int ok==-1;
   		set<int> st;
   		for(int i=0;i<n;i++){
   			cin>>arr[i];
   			st.insert(arr[i]);
   		}
   		if(st.size()==1){
   			cout<<1<<endl;
   			for(int i=0;i<n;i++)
   				cout<<1<<" ";
   			cout<<endl;
   			continue;
   		}
   		int ans[n]={0};
   		if(n%2==0){
   			cout<<2<<endl;
   			for(int i = 0;i<n;i++){
   				cout<<i%2+1<<" ";
   			}
   			cout<<endl;
   			continue;
   		}
   		for(int i=0;i<n;i++){
   			if(arr[i]==arr[(i+1)%n]){
   				ans[i] = ans[(i+1)%n] = 1;
   				ok = i;
   				break;
   			}
   		}
   		if(ok>=0){
   			for(int j = ok+2,t=0;j<n;j++,t=!t){
   				ans[j] = t;
   			}
   			for(int j=ok-1,t=0;j>=0;j--,t=!t){
   				ans[j]=t;
   			}
   			cout<<"2"<<endl;
   			for(int i=0;i<n;i++)
   				cout<<ans[i]+1<<" ";
   			cout<<endl;
   		}
   		else{
   			cout<<3<<endl;
   			for(int i=0;i<n-1;i++){
   				cout<<i%2+1<<" ";
   			}
   			cout<<3<<" ";
   			cout<<endl;
   		}
   	}

    return 0;
}


/*
	ID: sixathofpain
	TASK: carausel
	LANG: C++

*/

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;

   	int q;
   	cin>>q;
   	while(q--){
   		int n;
   		cin>>n;
   		int arr[n+2];
   		arr[0]=-1;
   		arr[n]= -1;
   		int ok=0;
   		set<int> st;
   		for(int i=0;i<n;i++){
   			cin>>arr[i];
   			st.insert(arr[i]);
   		}
   		if(st.size()==n){
   			cout<<1<<endl;
   			for(int i=0;i<n;i++)
   				cout<<1<<" ";
   			cout<<endl;
   			continue;
   		}
   		int ans[n]={0};
   		if(n%2==0){
   			cout<<2<<endl;
   			for(int i = 0;i<n;i++){
   				cout<<i%2+1<<" ";
   			}
   			cout<<endl;
   			continue;
   		}
   		for(int i=0;i<n;i++){
   			if(arr[i]==arr[(i+1)%n]){

   				ans[i] = ans[(i+1)%n] = 1;
   				ok = i;
   				break;
   			}
   		}
   		if(ok){
   			for(int j = ok+2,t=0;j<n;j++,t=!t){
   				ans[j] = t;
   			}
   			for(int j=ok-1,t=0;j>=0;j--,t=!t){
   				ans[j]=t;
   			}
   			cout<<"2"<<endl;
   			for(int i=0;i<n;i++)
   				cout<<ans[i]+1<<" ";
   			cout<<endl;
   		}
   		else{
   			cout<<3<<endl;
   			for(int i=0;i<n;i++){
   				cout<<n%3+1<<" ";
   			}
   			cout<<endl;
   		}
   	}

    return 0;
}


/*
	ID: sixathofpain
	TASK: carausel
	LANG: C++

*/

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;

   	int q;
   	cin>>q;
   	while(q--){
   		int n;
   		cin>>n;
   		int arr[n+2];
   		arr[0]=-1;
   		arr[n+1]= -1;
   		int ok=0;
   		for(int i = 1;i<=n;i++){
   			cin>>arr[i];
   			if(arr[i]==arr[i-1])
   				ok=1;
   		}
   		if(n%2==0 or (n+ok)%2==0){
   			cout<<"2"<<endl;
   			for(int i=0;i<n;i++){
   				if(arr[i]==arr[i+1] and ok){
   					cout<<i%2+1<<" "<<i%2+1<<" ";
   					i++;
   					ok=0;
   				}
   				else
   					cout<<i%2+1<<" ";
   			}
   			cout<<endl;
   		}else{
   			cout<<3<<endl;
   			for(int i=0;i<n;i++){
   				cout<<n%3+1<<" ";
   			}
   			cout<<endl;
   		}
   	}

    return 0;
}


//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define setbits(x) __builtin_popcount(x)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<db, db> pdd;
typedef vector<int> vi;
#define m1 make_pair
#define in insert
#define pb push_back
#define IOS                           \
    std::ios::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define endl "\n"
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

inline ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
inline ll power(ll a, ll n, ll m)
{
    if (n == 0)
        return 1;
    ll p = power(a, n / 2, m);
    p = (p * p) % m;
    if (n % 2)
        return (p * a) % m;
    else
        return p;
}
const ll MOD = 1000000007;
const int N = int(3e5) + 999;
#define int long long int

int32_t main(){
    IOS;
    int tc;
    cin>>tc;
    while(tc--){
    	int n;
    	cin>>n;
    	int arr[n];
    	for(int i =0;i<n;i++){
    		cin>>arr[i];
    	}
    	//case 1
    	int f=0;
    	for(int i =0;i<n;i++){
    		if(arr[i]!=arr[(i+1)%n])
    			f=1;
    	}
    	if(!f)
    	{
    		cout<<1<<endl;
    		for(int i=0;i<n;i++)
    			cout<<1<<" ";
    		cout<<endl;
    		continue;
    	}

    	int col[n];
    	int ans=2;
    	for (int i = 0; i < n; ++i)
    	{
    		/* code */
    		col[i]=i%2;
    	}

    	if(arr[0]!=arr[n-1] and col[0]==col[n-1]){
    		set<int> st;
    		st.insert(col[0]);
    		if(arr[n-2]!=arr[n-1])
    		st.insert(col[n-2]);
    		for(int i=0;i<=2;i++){
    			if(st.count(i)==0){
    				if(st.size()==2)
    					ans++;
    				col[n-1]=i;
    				break;
    			}
    		}
    	}

    	cout<<ans<<endl;
    	for(int i=0;i<n;i++){
    		cout<<col[i]+1<<" ";
    	}
    	cout<<endl;

    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
       else{
            vector<int> arr1(n);
            int count1 = 3;
            arr1[0] = 1;
            for(int i=1;i<n;i++){
                if(arr[i-1] == arr[i]){
                    count1 = 2;
                    for(int j=i;j<n;j++){
                        if(j%2==1) arr1[j] = 1;
                        else arr1[j] = 2;
                    }
                    break;
                }else{
                    if(i%2==0) arr1[i] = 1;
                    else arr1[i] = 2;
                }
            }
            if(count1==2 || arr[n-1] == arr[0]) cout << 2 << endl;
            else cout << 3<< endl;
            for(int i =0;i<n-1;i++){
                cout << arr1[i] << " ";
            }
            if(arr[n-1]==arr[0] && count1!=2) cout << 1;
            else if(count1==2) cout << arr1[n-1];
            else cout << 3;
            cout << endl;
            }
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
       else{
            vector<int> arr1(n);
            int count1 = 3;
            arr1[0] = 1;
            for(int i=1;i<n;i++){
                if(arr[i-1] == arr[i]){
                    count1 = 2;
                    for(int j=i;j<n;j++){
                        if(j%2==0) arr1[j] = 1;
                        else arr1[j] = 2;
                    }
                    break;
                }else{
                    if(i%2==0) arr1[i] = 1;
                    else arr1[i] = 2;
                }
            }
            cout << count1 << endl;
            for(int i =0;i<n-1;i++){
                cout << arr1[i] << " ";
            }
            if(count1>2) cout << 3;
            else cout << 2;
            cout << endl;
            }
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
       else{
            vector<int> arr1(n);
            int count1 = 3;
            arr1[0] = 1;
            for(int i=1;i<n;i++){
                if(arr[i-1] == arr[i]){
                    count1 = 2;
                    for(int j=i;j<n;j++){
                        if(j%2==1) arr1[j] = 1;
                        else arr1[j] = 2;
                    }
                    break;
                }else{
                    if(i%2==0) arr1[i] = 1;
                    else arr1[i] = 2;
                }
            }
            if(count1==2 || arr[n-1] == arr[0]) cout << 2 << endl;
            else cout << 3<< endl;
            for(int i =0;i<n-1;i++){
                cout << arr1[i] << " ";
            }
            if(arr[n-1]==arr[0]) cout << 2;
            else if(count1==2) cout << arr[n-1];
            else cout << 3;
            cout << endl;
            }
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
                            cout << endl;

            cout << 1 << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2 << endl;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
            }
        }
        else{
            if(arr[0]!=arr[n-1] && arr[n-2]!=arr[n-1]){
                cout << endl;
                cout << 3 << endl;
                for(int i=0;i<n-1;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
                cout << 3 << " ";
            }else{
                cout << endl;

                cout << 2 << endl;
                for(int i=0;i<n-1;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
                if(arr[n-1]==arr[n-2]){
                    cout << 2;
                }else{
                    cout << 1;
                }
            }
        }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
       else{
            vector<int> arr1(n);
            int count1 = 3;
            arr1[0] = 1;
            for(int i=1;i<n;i++){
                if(arr[i-1] == arr[i]){
                    count1 = 2;
                    for(int j=i;j<n;j++){
                        if(j%2==1) arr1[j] = 1;
                        else arr1[j] = 2;
                    }
                    break;
                }else{
                    if(arr1[i-1]==1) arr1[i] = 2;
                    else arr1[i] = 2;
                }
            }
            cout << count1 << endl;
            for(int i =0;i<n-1;i++){
                cout << arr1[i] << " ";
            }
            if(count1>2) cout << 3;
            else cout << 2;
            cout << endl;
            }
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
        else{
            vector<int> arr1(n);
            bool evn = false;
            arr1[0] =1,arr1[n-1] = 2,arr1[n-2] = 1;
            for(int i =1;i<n-2;i++){
                if(arr[i-1]==arr[i]){
                    evn = true;
                    for(int j=i;j<n-2;j++){
                        if(j%2==1) arr1[j] = 1;
                        else arr1[j] = 2;
                    }
                    break;
                }else {
                    if(arr1[i-1]==1){
                        arr1[i] = 2;
                    }else arr1[i] = 1;
                }
            }
            if(n==3){
                // todo if I put even here then
                int count1 =0;
                if(arr[n-1]!=arr[0] && arr[n-1]!=arr[n-2] && arr[0]!=arr[1]){
                    cout << 3 << endl;
                    for(int i=1;i<n+1;i++) cout << i << " ";
                }else{
                    cout << 2 << endl;
                    vector<int> arr2(3);
                    arr2[0]=1;
                    for(int i=1;i<n;i++){
                        if(arr[i-1]==arr[i]) arr2[i] = arr2[i-1];
                        else {
                            if(arr2[i-1]==1) arr2[i] =2;
                            else arr2[i] = 1;
                        }
                    }
                    cout << arr2[0] << " "<< arr2[1] << " "<<arr2[2];
                    cout << endl;
                }
            }
            else{
                if(arr[0]!=arr[n-1] && arr[n-2]!=arr[n-1]){
                    if(evn) cout << 2 << endl;
                    else cout << 3 << endl;
                    for(int i=0;i<n;i++){
                        cout << arr1[i] << " ";
                    }
                    cout << endl;
                }else{
                    cout << 2 << endl;
                    for(int i=0;i<n;i++) cout << arr1[i] << " ";
                    cout << endl;
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        unordered_map<int,int> val;
        int arr[n];
        for(int i=0;i<n;i++){
            cin>> arr[i] ;
        }
        int count1 =1;
        int outaarr[n+1];
        for(int i=0;i<n;i++){
            if(val.count(arr[i])>0){
                outaarr[i+1] = val[arr[i]];
                // cout << "first ";
            }else{
                outaarr[i+1] = count1;
                val[arr[i]]  = count1;
                count1++;
                // cout << val[arr[i]] << " ";
            }
        }
        cout << count1-1 << endl;
        for(int i=0;i<n;i++){
            cout << val[arr[i]]<< " ";
        }
        cout << endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1 <<endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
            }
            cout << endl;

        }
        else{
            if(arr[0]!=arr[n-1] && arr[n-2]!=arr[n-1]){
                // cout << endl;
                cout << 3 << endl;
                for(int i=0;i<n-1;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
                cout << 3 << " ";
                            cout << endl;

            }else{
                cout << 2 << endl;
                for(int i=0;i<n-1;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
                if(arr[n-1]==arr[n-2]){
                    cout << 2;
                }else{
                    cout << 1;
                }
                            cout << endl;

            }
        }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
        else{
            vector<int> arr1(n);
            bool evn = false;
            arr1[0] =1,arr1[n-1] = 2,arr1[n-2] = 1;
            for(int i =1;i<n-2;i++){
                if(arr[i-1]==arr[i]){
                    evn = true;
                    for(int j=i;j<n-2;j++){
                        if(j%2==1) arr1[j] = 1;
                        else arr1[j] = 2;
                    }
                    break;
                }else {
                    if(arr1[i-1]==1){
                        arr1[i] = 2;
                    }else arr1[i] = 1;
                }
            }
            if(n==3){
                // todo if I put even here then
                int count1 =0;
                if(arr[n-1]!=arr[0] && arr[n-1]!=arr[n-2] && arr[0]!=arr[1]){
                    cout << 3 << endl;
                    for(int i=1;i<n+1;i++) cout << i << " ";
                }else{
                    cout << 2 << endl;
                    vector<int> arr2(3);
                    arr2[0]=1;
                    for(int i=1;i<n;i++){
                        if(arr[i-1]==arr[i]) arr2[i] = arr2[i-1];
                        else {
                            if(arr2[i-1]==1) arr2[i] =2;
                            else arr2[i] = 1;
                        }
                    }
                    cout << arr2[0] << " "<< arr2[1] << " "<<arr2[2];
                    cout << endl;
                }
            }
            else{
                vector<int> arr1(n);
                int count1 = 3;
                for(int i=1;i<n;i++){
                    if(arr[i-1] == arr[i]){
                        count1 = 2;
                        for(int j=i;j<n;j++){
                            if(j%2==1) arr1[j] = 1;
                            else arr1[j] = 2;
                        }
                        break;
                    }else{
                        if(i%2==0) arr1[i] = 1;
                        else arr1[i] = 2;
                    }
                }
                cout << count1 << endl;
                for(int i =0;i<n;i++){
                    cout << arr1[i] << " ";
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
        else{
            vector<int> arr1(n);
            bool evn = false;
            arr1[0] =1,arr1[n-1] = 2,arr1[n-2] = 1;
            for(int i =1;i<n-2;i++){
                if(arr[i-1]==arr[i]){
                    evn = true;
                    for(int j=i;j<n-2;j++){
                        if(j%2==1) arr1[j] = 1;
                        else arr1[j] = 2;
                    }
                    break;
                }else {
                    if(arr1[i-1]==1){
                        arr1[i] = 2;
                    }else arr1[i] = 1;
                }
            }
            if(n==3){
                // todo if I put even here then
                int count1 =0;
                if(arr[n-1]!=arr[0] && arr[n-1]!=arr[n-2] && arr[0]!=arr[1]){
                    cout << 3 << endl;
                    for(int i=1;i<n+1;i++) cout << i << " ";
                }else{
                    cout << 2 << endl;
                    vector<int> arr2(3);
                    arr2[0]=1;
                    for(int i=1;i<n;i++){
                        if(arr[i-1]==arr[i]) arr2[i] = arr2[i-1];
                        else {
                            if(arr2[i-1]==1) arr2[i] =2;
                            else arr2[i] = 1;
                        }
                    }
                    cout << arr2[0] << " "<< arr2[1] << " "<<arr2[2];
                    cout << endl;
                }
            }
            else{
                if(arr[0]!=arr[n-1] && arr[n-2]!=arr[n-1]){
                    if(evn){
                        cout << 2 << endl;
                        for(int i=0;i<n;i++){
                        cout << arr1[i] << " ";
                    }
                    }
                    else {
                        cout << 3 << endl;
                        for(int i=0;i<n-1;i++){
                            if(i%2==0) cout << 1 << " ";
                            else cout << 2 << " ";
                        }
                        cout << 3;
                    }
                    cout << endl;
                }else{
                    cout << 2 << endl;
                    vector<int> arr3(n);
                    arr3[0] = 1;
                    for(int i=1;i<n-1;i++){
                        if(arr[i-1]==arr[i])arr3[i] = arr3[i-1];
                        else{
                            if(arr3[i-1]==1) arr3[i] = 2;
                            else arr3[i] = 1;
                        }
                    }
                    if(arr[n-1]==arr[n-2]) arr3[n-1] = 2;
                    if(arr[n-1]==arr[0]){
                        if(arr3[n-2]==1) arr3[n-1] = 2;
                        else arr3[n-1] = 1;
                    }
                    for(int i=0;i<n;i++){
                        cout << arr3[i] << " ";
                    }
                    cout << endl;
                }
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1 <<endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
            }
            cout << endl;

        }else if(n==3 &&(arr[0]==arr[1])){
            cout << 2 << endl;
            cout << 1 << " "<< 1 << " " << 2;
            cout << endl;
        }
        else{
            if(arr[0]!=arr[n-1] && arr[n-2]!=arr[n-1]){
                // cout << endl;
                cout << 3 << endl;
                for(int i=0;i<n-1;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
                cout << 3 << " ";
                            cout << endl;

            }else{

                cout << 2 << endl;
                for(int i=0;i<n-1;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
                if(arr[n-1]==arr[n-2]){
                    cout << 2;
                }else{
                    cout << 1;
                }
                            cout << endl;

            }
        }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1 << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
            return 0;
        }
        else if(n%2==0){
            cout << 2 << endl;
            for(int i=0;i<n;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
            }
            return 0;
        }
        else{
            if(arr[0]!=arr[n-1]){
                cout << 3 << endl;
                for(int i=0;i<n-1;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
                cout << 3 << " ";
            }else{
                cout << 2 << endl;
                for(int i=0;i<n;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
            }
        }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
       else{
            vector<int> arr1(n);
            int count1 = 3;
            arr1[0] = 1;
            for(int i=1;i<n;i++){
                if(arr[i-1] == arr[i]){
                    count1 = 2;
                    for(int j=i;j<n;j++){
                        if(j%2==1) arr1[j] = 1;
                        else arr1[j] = 2;
                    }
                    break;
                }else{
                    if(i%2==0) arr1[i] = 1;
                    else arr1[i] = 2;
                }
            }
            if(count1==2 || arr[n-1] == arr[0]) cout << 2 << endl;
            else cout << 3<< endl;
            for(int i =0;i<n-1;i++){
                cout << arr1[i] << " ";
            }
            if(arr[n-1]==arr[0]) cout << 2;
            else if(count1==2) cout << arr1[n-1];
            else cout << 3;
            cout << endl;
            }
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1 << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
            return 0;
        }
        else if(n%2==0){
            cout << 2 << endl;
            for(int i=0;i<n;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
            }
            return 0;
        }
        else{
            if(arr[0]!=arr[n-1]){
                cout << 3 << endl;
                for(int i=0;i<n-1;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
                cout << 3 << " ";
            }else{
                cout << 2 << endl;
                for(int i=0;i<n;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
            }
        }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
       else{
            vector<int> arr1(n);
            int count1 = 3;
            arr1[0] = 1;
            for(int i=1;i<n;i++){
                if(arr[i-1] == arr[i]){
                    count1 = 2;
                    for(int j=i;j<n;j++){
                        if(j%2==1) arr1[j] = 1;
                        else arr1[j] = 2;
                    }
                    break;
                }else{
                    if(arr1[i-1]==1) arr1[i] = 2;
                    else arr1[i] = 1;
                }
            }
            cout << count1 << endl;
            for(int i =0;i<n-1;i++){
                cout << arr1[i] << " ";
            }
            if(count1>2) cout << 3;
            else cout << 2;
            cout << endl;
            }
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
        else{
            vector<int> arr1(n);
            bool evn = false;
            arr1[0] =1,arr1[n-1] = 2,arr1[n-2] = 1;
            for(int i =1;i<n-2;i++){
                if(arr[i-1]==arr[i]){
                    evn = true;
                    for(int j=i;j<n-2;j++){
                        if(j%2==1) arr1[j] = 1;
                        else arr1[j] = 2;
                    }
                    break;
                }else {
                    if(arr1[i-1]==1){
                        arr1[i] = 2;
                    }else arr1[i] = 1;
                }
            }
            if(n==3){
                // todo if I put even here then
                int count1 =0;
                if(arr[n-1]!=arr[0] && arr[n-1]!=arr[n-2] && arr[0]!=arr[1]){
                    cout << 3 << endl;
                    for(int i=1;i<n+1;i++) cout << i << " ";
                }else{
                    cout << 2 << endl;
                    vector<int> arr2(3);
                    arr2[0]=1;
                    for(int i=1;i<n;i++){
                        if(arr[i-1]==arr[i]) arr2[i] = arr2[i-1];
                        else {
                            if(arr2[i-1]==1) arr2[i] =2;
                            else arr2[i] = 1;
                        }
                    }
                    cout << arr2[0] << " "<< arr2[1] << " "<<arr2[2];
                    cout << endl;
                }
            }
            else{
                vector<int> arr1(n);
                int count1 = 3;
                arr1[0] = 1;
                for(int i=1;i<n;i++){
                    if(arr[i-1] == arr[i]){
                        count1 = 2;
                        for(int j=i;j<n;j++){
                            if(j%2==1) arr1[j] = 1;
                            else arr1[j] = 2;
                        }
                        break;
                    }else{
                        if(i%2==0) arr1[i] = 1;
                        else arr1[i] = 2;
                    }
                }
                cout << count1 << endl;
                for(int i =0;i<n-1;i++){
                    cout << arr1[i] << " ";
                }
                if(count1>2) cout << 3;
                else cout << 2;
                cout << endl;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1 << endl;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2 << endl;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
            }
        }
        else{
            if(arr[0]!=arr[n-1] && arr[n-2]!=arr[n-1]){
                cout << 3 << endl;
                cout << endl;
                for(int i=0;i<n-1;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
                cout << 3 << " ";
            }else{
                cout << 2 << endl;
                cout << endl;
                for(int i=0;i<n;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
            }
        }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
       else{
            vector<int> arr1(n);
            int count1 = 3;
            arr1[0] = 1;
            for(int i=1;i<n;i++){
                if(arr[i-1] == arr[i]){
                    count1 = 2;
                    for(int j=i;j<n;j++){
                        if(j%2==1) arr1[j] = 1;
                        else arr1[j] = 2;
                    }
                    break;
                }else{
                    if(i%2==0) arr1[i] = 1;
                    else arr1[i] = 2;
                }
            }
            if(count1==2 || arr[n-1] == arr[0]) cout << 2;
            else cout << 3;
            for(int i =0;i<n-1;i++){
                cout << arr1[i] << " ";
            }
            if(arr[n-1]==arr[0]) cout << 2;
            else if(count1==2) cout << arr[n-1];
            else cout << 3;
            cout << endl;
            }
        }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    while(t--){
        int n;
        unordered_map<int,int> val;
        int arr[n];
        for(int i=0;i<n;i++){
            cin>> arr[i] ;
        }
        int count =1;
        int outaarr[n+1];
        for(int i=0;i<n;i++){
            if(val.count(arr[i])>0){
                outaarr[i+1] = val[arr[i]];
            }else{
                count++;
                outaarr[i+1] = count;
                val[arr[i]]  = count;
            }
        }
        for(int i=0;i<n;i++){
            cout << outaarr[i+1]<< " ";
        }
        cout << endl;
    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1 << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2 << endl;
            for(int i=0;i<n;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
            }
        }
        else{
            if(arr[0]!=arr[n-1]){
                cout << 3 << endl;
                for(int i=0;i<n-1;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
                cout << 3 << " ";
            }else{
                cout << 2 << endl;
                for(int i=0;i<n;i++){
                if(i%2==0){
                    cout << 1 << " ";
                }else{
                    cout << 2 << " ";
                }
                }
            }
        }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
        else{
            vector<int> arr1(n);
            arr1[0] = 1;
            int count1=2;
            for(int i=1;i<n;i++){
                if(arr[i-1]==arr[i]) arr1[i] = arr1[i-1];
                else{
                    if(arr1[i-1]==1) arr1[i] = 2;
                    else arr1[i] = 1;
                }
            }
            if(arr[n-1]!=arr[0] && arr[n-1]!=arr[n-2]){
                if(arr1[n-2]==1) arr1[n-1] = 2;
                else {
                    arr1[n-1] = 3;
                    count1 = 3;
                }
            }else if(arr[n-1]==arr[0] && arr[n-2]!=arr[n-1]){
                if(arr1[n-2]==1) arr1[n-1] = 2;
                else arr1[n-1] = 1;
            }else{
                arr1[n-1] = 2;
            }
            cout << count1 << endl;
            for(int i=0;i<n;i++){
                cout << arr1[i] << " ";
            }
            cout << endl;
        }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
        else{
            vector<int> arr1(n);
            arr1[0] = 1;
            int count1=2;
            for(int i=1;i<n;i++){
                if(arr[i-1]==arr[i]) arr1[i] = arr1[i-1];
                else{
                    if(arr1[i-1]==1) arr1[i] = 2;
                    else arr1[i] = 1;
                }
            }
            if(arr[n-1]!=arr[0] && arr[n-1]!=arr[n-2]){
                if(arr1[n-2]==1) arr1[n-1] = 2;
                else {
                    arr1[n-1] = 3;
                    count1 = 3;
                }
            }else if(arr[n-1]==arr[0] && arr[n-2]!=arr[n-1]){
                if(arr1[n-2]==1) arr1[n-1] = 2;
                else arr1[n-1] = 1;
            }else{
                arr1[n-1] = 2;
            }
            cout << count1 << endl;
            for(int i=0;i<n;i++){
                cout << arr1[i] << " ";
            }
            cout << endl;
        }

    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
        else{
            vector<int> arr1(n);
            bool evn = false;
            arr1[0] =1,arr1[n-1] = 2,arr1[n-2] = 1;
            for(int i =1;i<n-2;i++){
                if(arr[i-1]==arr[i]){
                    evn = true;
                    for(int j=i;j<n-2;j++){
                        if(j%2==1) arr1[j] = 1;
                        else arr1[j] = 2;
                    }
                    break;
                }else {
                    if(arr1[i-1]==1){
                        arr1[i] = 2;
                    }else arr1[i] = 1;
                }
            }
            if(n==3){
                // todo if I put even here then
                int count1 =0;
                if(arr[n-1]!=arr[0] && arr[n-1]!=arr[n-2] && arr[0]!=arr[1]){
                    cout << 3 << endl;
                    for(int i=1;i<n+1;i++) cout << i << " ";
                }else{
                    cout << 2 << endl;
                    vector<int> arr2(3);
                    arr2[0]=1;
                    for(int i=1;i<n;i++){
                        if(arr[i-1]==arr[i]) arr2[i] = arr2[i-1];
                        else {
                            if(arr2[i-1]==1) arr2[i] =2;
                            else arr2[i] = 1;
                        }
                    }
                    cout << arr2[0] << " "<< arr2[1] << " "<<arr2[2];
                    cout << endl;
                }
            }
            else{
                vector<int> arr1(n);
                int count1 = 3;
                arr1[0] = 1;
                for(int i=1;i<n;i++){
                    if(arr[i-1] == arr[i]){
                        count1 = 2;
                        for(int j=i;j<n;j++){
                            if(j%2==0) arr1[j] = 1;
                            else arr1[j] = 2;
                        }
                        break;
                    }else{
                        if(i%2==0) arr1[i] = 1;
                        else arr1[i] = 2;
                    }
                }
                cout << count1 << endl;
                for(int i =0;i<n-1;i++){
                    cout << arr1[i] << " ";
                }
                if(count1>2) cout << 3;
                else cout << 2;
                cout << endl;
            }
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        unordered_map<int,int> val;
        int arr[n];
        for(int i=0;i<n;i++){
            cin>> arr[i] ;
        }
        int count1 =1;
        int outaarr[n+1];
        for(int i=0;i<n;i++){
            if(val.count(arr[i])>0){
                outaarr[i+1] = val[arr[i]];
                // cout << "first ";
            }else{
                outaarr[i+1] = count1;
                val[arr[i]]  = count1;
                count1++;
                // cout << val[arr[i]] << " ";
            }
        }
        for(int i=0;i<n;i++){
            cout << val[arr[i]]<< " ";
        }
        cout << endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
            cin >> arr[i];
        }
        if(count(arr.begin(),arr.end(),arr[0])==n){
            cout << 1;
            cout << endl;
            for(int i=0;i<n;i++){
                cout << 1 << " ";
            }
            cout << endl;
        }
        else if(n%2==0){
            cout << 2;
            cout << endl;

            for(int i=0;i<n;i++){
                if(i%2==0) cout << 1 << " ";
                else cout << 2 << " ";
            }
            cout << endl;
        }
        else{
            vector<int> arr1(n);
            arr1[0] = 1;
            int count1=2;
            for(int i=1;i<n;i++){
                if(arr[i-1]==arr[i]) arr1[i] = arr1[i-1];
                else{
                    if(arr1[i-1]==1) arr1[i] = 2;
                    else arr1[i] = 1;
                }
            }
            if(arr[n-1]!=arr[0] && arr[n-1]!=arr[n-2]){
                if(arr1[n-2]==1) arr1[n-1] = 2;
                else {
                    arr1[n-1] = 3;
                    count1 = 3;
                }
            }else if(arr[n-1]==arr[0] && arr[n-2]!=arr[n-1]){
                if(arr1[n-2]==1) arr1[n-1] = 2;
                else arr1[n-1] = 1;
            }else{
                arr1[n-1] = 2;
            }
            cout << count1 << endl;
            for(int i=0;i<n;i++){
                cout << arr1[i] << " ";
            }
            cout << endl;
        }

    }
    return 0;
}


// codeforces/629div3/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int _;
  cin >> _;

  int n;
  while (cin >> n) {
    vec<int> v(n);
    cin >> v;

    bool f = true;
    each (i, v) f = f && (v.front() == i);
    if (f) {
      cout << 1 << endl;
      for (int i = 0; i < n; ++i) {
        cout << 1 << ' ';
      }
      cout << endl;
      continue;
    }

    vec<int> u;
    for (int i = 0; i < v.size(); ++i) {
      u.push_back(i % 2);
    }

    if (u.back() == u.front() && v.back() != v.front()) {
      int k = -1;
      for (int i = 0; i + 1 < v.size(); ++i) {
        if (v[i] == v[i + 1]) {
          k = i + 1;
          break;
        }
      }
      if (k == -1) {
        u.back() = 2;
      } else {
        for (int i = k; i < v.size(); ++i) {
          v[i] = (i + 1) % 2;
        }
      }
    }
    set<int> vis;
    each (i, u) vis.insert(i);
    cout << vis.size() << endl;
    each (i, u) cout << i+1 << ' '; cout << endl;
  }

  return 0;
}


// codeforces/629div3/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int _;
  cin >> _;

  int n;
  while (cin >> n) {
    vec<int> v(n);
    cin >> v;

    vec<int> u;

    u.push_back(0);
    for (int i = 1; i < v.size(); ++i) {
      if (v[i - 1] != v[i]) {
        u.push_back((u.back() + 1) % 2);
      } else {
        u.push_back(u.back());
      }
    }

    if (v.back() != v.front() && u.front() == u.back()) {
      int x = u.back();
      int cnt = 0;
      while (u.back() == x) {
        ++cnt;
        u.pop_back();
      }
      while (cnt--) {
        u.push_back(2);
      }
    }

    set<int> vis;
    each (i, u) vis.insert(i);
    cout << vis.size() << endl;
    each (i, u) cout << i + 1 << ' '; cout << endl;
  }

  return 0;
}


// codeforces/629div3/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  int _;
  cin >> _;

  int n;
  while (cin >> n) {
    vec<int> v(n);
    cin >> v;

    map<int, int> m;
    int c = 0;
    v[v[0]] = c;
    for (int i = 1; i < v.size(); ++i) {
      if (v[i - 1] != v[i]) {
        c = (c + 1) % 2;
      }
      m[v[i]] = c;
    }

    if (m[v.front()] == m[v.back()] && v.front() != v.back()) {
      m[v.back()] = 2;
    }

    set<int> vis;
    each (i, v) vis.insert(m[i]);
    cout << vis.size() << endl;
    each (i, v) cout << m[i] + 1 << ' '; cout << endl;
  }

  return 0;
}