# cf 629div.3 d题#2一直挂QWQ，求助dalao

@邵之航 2020-03-27 00:41 回复
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PII pair<int,int>
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define fo(i,a,b) for(int i=a;i>=b;i--)
//#pragma GCC optimize(2)
char ch = getchar(); int x = 0, f = 1;
while(ch < '0' || ch > '9') {
if(ch == '-') f = -1;
ch = getchar();
} while('0' <= ch && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
} return x * f;
}*/
int t,n,a[200005],b[200005];
int main(){
scanf("%d",&t);
while(t--){
int flag=0,sum=0,ans;
scanf("%d",&n);
fr(i,1,n) {
scanf("%d",&a[i]);
if(a[i]!=a[1]) flag=1;
}
if(flag==0) {
printf("1\n");
fr(i,1,n) printf("%d ",1);
printf("\n");
continue;
}
flag=0;
fr(i,1,n){
if(a[i]!=a[i-1]) sum++;
else flag=1;
}
//cout<<sum;
if(sum%2==0) ans=2;
else {
if(flag==1) ans=2;
else ans=3;
}
b[1]=1;
int f=0;
if(sum%2==1&&flag==1){
fr(i,2,n){
if(a[i]!=a[i-1]) b[i]=3-b[i-1];
else{
if(f==0) b[i]=3-b[i-1],f=1;
else b[i]=b[i-1];
}
}
}
else {
fr(i,2,n){
if(a[i]!=a[i-1]) b[i]=3-b[i-1];
else b[i]=b[i-1];
}
}
if(sum%2==1&&flag==0)
b[n]=3;
printf("%d\n",ans);
fr(i,1,n) printf("%d ",b[i]);
cout<<endl;
}
return 0;
}