The round carousel consists of nn figures of animals. Figures are numbered from 11 to nn in order of the carousel moving. Thus, after the nn-th figure the figure with the number 11 follows. Each figure has its own type — the type of the animal corresponding to this figure (the horse, the tiger and so on). The type of animal of the ii-th figure equals tit_i.
CF1328D.png
You want to color each figure in one of the colors. You think that it’s boring if the carousel contains two different figures (with the distinct types of animals) going one right after another and colored in the same color.
Your task is to color the figures in such a way that the number of distinct colors used is the minimum possible and there are no figures of the different types going one right after another and colored in the same color. If you use exactly kk distinct colors, then the colors of figures should be denoted with integers from 11 to kk.

Input

The input contains one or more test cases.
The first line contains one integer qq (1q104)(1≤q≤10^4) — the number of test cases in the test. Then q test cases follow. One test case is given on two lines.
The first line of the test case contains one integer nn (3n2105)(3≤n≤2⋅10^5) — the number of figures in the carousel. Figures are numbered from 1 to n in order of carousel moving. Assume that after the n-th figure the figure 1 goes.
The second line of the test case contains nn integers t1,t2,,tnt_1,t_2,…,t_n (1ti2105)(1≤t_i≤2⋅10^5), where tit_i is the type of the animal of the ii-th figure.
The sum of nn over all test cases does not exceed 21052⋅10^5.

Output

Print qq answers, for each test case print two lines.
In the first line print one integer kk — the minimum possible number of distinct colors of figures.
In the second line print nn integers c1,c2,,cnc_1,c_2,…,c_n (1cik)(1≤c_i≤k), where cic_i is the color of the ii-th figure. If there are several answers, you can print any.

Example

input

1
2
3
4
5
6
7
8
9
4
5
1 2 1 2 2
6
1 2 2 1 2 2
5
1 2 1 2 3
3
10 10 10

output

1
2
3
4
5
6
7
8
2
1 2 1 2 2
2
2 1 2 1 2 1
3
2 3 2 3 1
1
1 1 1

Translation

已知一个有 nn (3n21053\le n\le 2\cdot 10^5) 个点的环,点 ii 的类型为 tit_i。现在需要给每个点进行染色,要求相邻不同类型的点的颜色不同且所用颜色数最小。输出颜色数及一种染色方案即可(颜色从 11 开始)。

Idea

学过离散数学都知道,环的色数至多为 33,而题目中环上相邻点若为同一类型,还可以染相同颜色,故需要颜色数至多为 33
nn 个点都是同一种类型,就染一个颜色。
若要染两个及以上颜色,那么 nn 个点至少有两种不同类型。此时染两种颜色的情况有二:1)nn 为偶数,1122 交替染即可;2)nn 为奇数,但是存在一个位置 pppp 的一个相邻位 qqppqq 的类型相同,那么将 ppqq 取相同颜色,然后得到以 pp 开头的奇数长度链,和 qq 开头的偶数长度链,分别依次染色 1122。其余情况就需要染三种颜色。

Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/******************************************************************
Copyright: 11D_Beyonder All Rights Reserved
Author: 11D_Beyonder
Problem ID: CF1328D
Date: 01/14/2020
Description: Construction, Graph, Greedy
*******************************************************************/
#include<iostream>
#include<unordered_set>
#include<algorithm>
using namespace std;
const int N=200005;
int t[N];
int _,n;
int c[N];
int main(){
for(cin>>_;_;_--){
cin>>n;
unordered_set<int>ex;
for(int i=1;i<=n;i++){
cin>>t[i];
ex.insert(t[i]);
}
if(ex.size()==1){
//只有一种类型
cout<<1<<endl;
for(int i=1;i<=n;i++){
cout<<"1 ";
}
}else if(n%2==0){
//偶数个点
cout<<2<<endl;
for(int i=1;i<=n;i+=2){
cout<<"1 2 ";
}
}else{
//寻找相邻位置相同种类
//找不到就3种颜色
if(t[1]==t[n]){
//首尾相同
cout<<2<<endl;
for(int i=1;i<n;i+=2){
cout<<"1 2 ";
}
cout<<1;
}else{
int p=-1;
for(int i=1;i<n;i++){
if(t[i]==t[i+1]){
p=i;
break;
}
}
if(~p){
cout<<2<<endl;
if(p&1){
//1~p是奇数个 p+1~n是偶数个
for(int i=1;i<p;i+=2){
cout<<"1 2 ";
}
cout<<"1 ";
for(int i=p+1;i<=n;i+=2){
cout<<"1 2 ";
}
}else{
//1~p是偶数个 p+1~n是奇数个
for(int i=1;i<=p;i+=2){
cout<<"1 2 ";
}
for(int i=p+1;i<n;i+=2){
cout<<"2 1 ";
}
cout<<2;
}
}else{
cout<<3<<endl;
for(int i=1;i<n;i+=2){
cout<<"1 2 ";
}
cout<<3;
}
}
}
cout<<endl;
}
return 0;
}