#include<bits/stdc++.h>usingnamespace std;#definefifirst#definesesecond#defineIOSstd::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);#defineintlonglongconstint N =2e6+10;constint mod =1e9+7;typedef pair<int,int>PII;/*
3
1 2 3 4 5
1 2 1 2 1
*/int n , t;int a[N], ans[N];signedmain(){
IOS
cin >> t;while(t --){
cin >> n;bool tag =0;int now =0;
map<int,int>mp;for(int i =0; i < n ; i ++){
cin >> a[i];
mp[a[i]]=1;}for(int i =0; i < n ; i ++){if(a[i]== a[(i +1)% n]) tag =1, now =(i +1)% n;}if(mp.size()==1){
cout <<"1\n";for(int i =0; i < n ; i ++) ans[i]=1;}else{if(n %2==0){
cout <<"2\n";for(int i =0; i < n ; i ++){if(i &1) ans[i]=1;else ans[i]=2;}}elseif(tag){
cout <<"2\n";for(int i =1, j = now ; i <= n ; i ++, j =(j +1)% n){if(i &1) ans[j]=1;else ans[j]=2;}}else{
cout <<"3\n";for(int i =0; i < n -1; i ++){if(i &1) ans[i]=1;else ans[i]=2;}
ans[n -1]=3;}}for(int i =0; i < n ; i ++) cout << ans[i]<<" ";
cout <<"\n";}return0;}//freopen("文件名.in","r",stdin);//freopen("文件名.out","w",stdout);