链接:https://codeforces.ml/contest/1328/problem/D

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 titi.

14b03eb81d32a3e2f92254a8c4ea43e5871f2a6d.pnguploading.4e448015.gif正在上传…重新上传取消The example of the carousel for n=9n=9 and t=[5,5,1,15,1,5,5,1,1]t=[5,5,1,15,1,5,5,1,1].

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 (1≤q≤1041≤q≤104) — the number of test cases in the test. Then qq test cases follow. One test case is given on two lines.

The first line of the test case contains one integer nn (3≤n≤2⋅1053≤n≤2⋅105) — the number of figures in the carousel. Figures are numbered from 11 to nn in order of carousel moving. Assume that after the nn-th figure the figure 11 goes.

The second line of the test case contains nn integers t1,t2,…,tnt1,t2,…,tn (1≤ti≤2⋅1051≤ti≤2⋅105), where titi is the type of the animal of the ii-th figure.

The sum of nn over all test cases does not exceed 2⋅1052⋅105.

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,…,cnc1,c2,…,cn (1≤ci≤k1≤ci≤k), where cici is the color of the ii-th figure. If there are several answers, you can print any.

Example

input

Copy

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

Copy

2
1 2 1 2 2
2
2 1 2 1 2 1
3
2 3 2 3 1
1
1 1 1 

代码:

#include<bits/stdc++.h>
using namespace std;
long long n,h,k,l,t,u,v,max1=0;
map<long long,long long>m[200001];
long long a[200001],b[200001],d[200001],c[200001];
int main()
{
cin>>t;
    while(t--)
    {
        cin>>n;
        int flag=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
        a[0]=a[n];
        int cnt=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==a[1])
            {
                cnt++;
            }
        }
        if(cnt==n)
        {
            cout<<1<<endl;
            for(int i=1; i<=n; i++)
            {
                cout<<1<<' ';
            }
            cout<<endl;
            continue;
        }
        cnt=0;
        flag=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i]==a[(i+1)%n])
            {
                flag=1;
            }
            else
            {
                cnt++;
            }
        }
        if(cnt%2==1)
        {
            if(flag==1)
            {
                cout<<2<<endl;
                cnt=0;
                flag=0;
                for(int i=1; i<=n; i++)
                {
                    if(cnt==0)
                    {
                        cout<<1<<' ';
                    }
                    else
                    {
                        cout<<2<<' ';
                    }
                    if(a[i]==a[(i+1)%n])
                    {
                        if(flag==0)
                        {
                            flag++;
                            cnt++;
                            cnt%=2;
                        }
                    }
                    else
                    {
                        cnt++;
                        cnt%=2;
                    }
                }
                cout<<endl;
            }
            else
            {
                cout<<3<<endl;
                if(n%3==1)
                {
                    for(int i=1; i<=n-1; i++)
                    {
                        cout<<i%3+1<<' ';
                    }
                    cout<<3;
                }
                else
                {
                    for(int i=1; i<=n; i++)
                    {
                        cout<<i%3+1<<' ';
                    }
                }
                cout<<endl;
            }
        }
        else
        {
            cout<<2<<endl;
            cnt=0;
            for(int i=1; i<=n; i++)
            {
                if(cnt==0)
                {
                    cout<<1<<' ';
                }
                else
                {
                    cout<<2<<' ';
                }
                if(a[i]!=a[(i+1)%n])
                {
                    cnt++;
                    cnt%=2;
                }
            }
            cout<<endl;
        }
    }
    return 0;
}