#include<iostream>
#include<stdio.h>
#include<math.h>
#include<bits/stdc++.h>
using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[n],b[n],arr[n];
   arr[n]={0};
   for(int i=0;i<n;i++){
      cin>>a[i]>>b[i];
   }
   for(int i=0;i<n;i++){
      arr[i] = arr[i]-a[i];
      arr[i] = arr[i]+b[i];
   }
   cout<<*max_element(arr,arr+n)<<endl;
}


#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[n],b[n],arr[n];
   arr[n]={0};
   for(int i=0;i<n;i++){
      cin>>a[i]>>b[i];
   }
   for(int i=0;i<n;i++){
      arr[i] = arr[i]-a[i];
      arr[i] = arr[i]+b[i];
   }
   cout<<max(arr)<<endl;
}


#include<iostream>
#include<stdio.h>
#include<math.h>
#include<bits/stdc++.h>
using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[n],b[n],arr[n];
   arr[n]={0};
   for(int i=0;i<n;i++){
      cin>>a[i]>>b[i];
   }
   int ans,k=0;
   for(int i=0;i<n;i++){
      ans=b[i]-a[i]+k;
      arr[i]=ans;

   }
   int max = 0;
   for(int i=0;i<n;i++){
      if(arr[i]>max){
         max=arr[i];
      }
   }
   cout<<max<<endl;
}


#include<iostream>
#include<stdio.h>
#include<math.h>
#include<bits/stdc++.h>
using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[n],b[n],arr[n];
   arr[n]={0};
   for(int i=0;i<n;i++){
      cin>>a[i]>>b[i];
   }
   for(int i=0;i<n;i++){
      arr[i] = arr[i]-a[i];
      arr[i] = arr[i]+b[i];
   }
   int max = 0;
   for(int i=0;i<n;i++){
      if(arr[i]>max){
         max=arr[i];
      }
   }
   cout<<max<<endl;
}


#include<iostream>
#include<stdio.h>
#include<math.h>
#include<bits/stdc++.h>
using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[n],b[n],arr[n];
   arr[n]={0};
   for(int i=0;i<n;i++){
      cin>>a[i]>>b[i];
   }
   for(int i=0;i<n;i++){
      arr[i] = arr[i]-a[i]+b[i];
   }
   int max = 0;
   for(int i=0;i<n;i++){
      if(arr[i]>max){
         max=arr[i];
      }
   }
   cout<<max<<endl;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin>>n;
	int a,b,cap,tmp;
	while(n--)
	{
		cin>>a>>b;
		cap+=b;
	}
	cout<<cap-a;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

int main() {
	int n;
	cin>>n;
	while(n--)
	{
		int a,b,cap,tmp;
		cin>>a>>b;
		cap+=b;
	}
	cout<<cap-a;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	int a,b,cap,tmp, max;
	max=0;
	while(n--)
	{
		cin>>a>>b;
		tmp=tmp+b-a;
		if(tmp>max) {
		max=tmp;
		}
	}
	cout<<max;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	int a,b,cap,tmp, max;
	while(n--)
	{
		cin>>a>>b;
		tmp=tmp+b-a;
		if(tmp>max)
		max=tmp;
	}
	cout<<max;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	int a,b,cap,tmp, max;
	while(n--)
	{
		cin>>a>>b;
		tmp=tmp+b-a;
		if(tmp>max){
		max=tmp;
		}
	}
	cout<<max;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	int a,b,cap,tmp, max;
	tmp=max=0;
	while(n--)
	{
		cin>>a>>b;
		tmp=tmp+b-a;
		if(tmp>max){
		max=tmp;
		}
	}
	cout<<max;
	return 0;
}


 #include<bits/stdc++.h>

using namespace std;
int main()
{
  int n,a,b,sum=0,k=0;
  cin>>n;
  int x1[n],x2[n];
  for(int i=0;i<n;i++)
  {
      cin>>a>>b;
      x1[i]=a; x2[i]=b;
  }
  for(int i=0;i<n;i++)
  {
      sum=x2[i]-x1[i+1]+x2[i+1];
      if(sum>k)
        k=sum;
  }
  cout<<k<<endl;;
 return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main()
{
  int n,a,b,sum=0,k=0;
  cin>>n;
  int a1[n],b1[n];
  for(int i=0;i<n;i++)
  {
      cin>>a>>b;
      a1[i]=a; b1[i]=b;
  }
  for(int i=0;i<n-1;i++)
  {
     sum=b1[i]-a1[i+1]+b1[i+1];
     b1[i+1]+=(b1[i]-a1[i+1]);
     if(sum>k)
        k=sum;
  }
  cout<<k<<endl;
 return 0;
}


#include<bits/stdc++.h>

using namespace std;
int main()
{
  int n,a,b,sum=0,k=0;
  cin>>n;
  int a1[n],b1[n];
  for(int i=0;i<n;i++)
  {
      cin>>a>>b;
      a1[i]=a; b1[i]=b;
  }
  for(int i=0;i<n-1;i++)
  {
     sum=b1[i]-a1[i+1];
     if(b1[i+1]==0)
      b1[i+1]=b1[i];
     else
      b1[i+1]+=sum;
     if(b1[i+1]>k)
        k=b1[i+1];

  }
  cout<<k<<endl;
 return 0;
}


 #include<bits/stdc++.h>

using namespace std;
int main()
{
  int n,a,b,sum=0,k=0;
  cin>>n;
  int a1[n],b1[n];
  for(int i=0;i<n;i++)
  {
      cin>>a>>b;
      a1[i]=a; b1[i]=b;
  }
  for(int i=0;i<n;i++)
  {
     sum=b1[i]-a1[i+1]+b1[i+1];
     b1[i+1]+=(b1[i]-a1[i+1]);
     if(sum>k)
        k=sum;
  }
  cout<<k<<endl;
 return 0;
}


 #include<bits/stdc++.h>

using namespace std;
int main()
{
  int n,a,b,x=0;
  cin>>n;
  for(int i=0;i<n;i++)
  {
   cin>>a>>b;
   if(a>=b)
    x+=(a-b);
   else
    x+=(b-a);
  }
  cout<<x/2<<endl;
 return 0;
}


 #include<bits/stdc++.h>

using namespace std;
int main()
{
   int n,a,b,x=0,y=0;
   cin>>n;
   for(int i=0;i<n;i++)
   {
       cin>>a>>b;
       x-=a;
       x+=b;
       if(x>y)
        y=x;
   }
   cout<<y<<endl;
 return 0;
}


 #include<bits/stdc++.h>

using namespace std;
int main()
{
  int n,a,b,sum=0,k=0;
  cin>>n;
  int a1[n],b1[n];
  for(int i=0;i<n;i++)
  {
      cin>>a>>b;
      a1[i]=a; b1[i]=b;
  }
  for(int i=0;i<n-1;i++)
  {
     sum=b1[i]-a1[i+1]+b1[i+1];
     if(sum==0)
        sum=b1[i];
      b1[i+1]+=(b1[i]-a1[i+1]);
     if(sum>k)
        k=sum;

  }
  cout<<k<<endl;
 return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int n,a,b,c(0),d(0);
    cin>>n;
    while(n--)
    {

        cin>>a>>b;
        c-= a;
        c+=b;
        if(c>d)
            {

             d=c;
             }
            cout<<d<<endl;
          }
          return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int n,c(0),d(0);
    cin>>n;
    while(n--)
    {
        int a,b;
        cin>>a>>b;
        c-= a;
        c+=b;
        if(c>d)
            {

             d=c;
             }
            cout<<d<<endl;
          }
          return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int n,c(0),d(0);
    cin>>n;
    while(n--)
    {
        int a,b;
        cin>>a>>b;
        c-= a;
        c+=b;
        if(d>a)
            {

             d=c;
             }
            cout<<d<<endl;
          }
          return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int n,a,b,c(0),d(0);
    cin>>n;
    while(n--)
    {

        cin>>a>>b;
        c -= a;
        c += b;
        if(c>d)
            {

             d=c;
             }

          }
           cout<<d<<endl;
          return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int n,a,b,c(0),d(0);
    cin>>n;
    while(n--)
    {

        cin>>a>>b;
        c -= a;
        c += b;
        if(c>d)
            {

             d=c;
             }
            cout<<d<<endl;
          }
          return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int n,c(0),d(0);
    cin>>n;
    while(n--)
    {
        int a,b;
        cin>>a>>b;
        c-= a;
        c+=b;
        if(d>a)
            {

             d=c;
             }
            cout<<a<<endl;
          }
          return 0;
}


#include<iostream>
using namespace std;

int main()
{
    int n,c(0),a(0);
    cin>>n;
    while(n--)
    {
        int a,b;
        cin>>a>>b;
        c-= a;
        c+=b;
        if(c>a)
            {

             a=c;
             }
            cout<<a<<endl;
          }
          return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a,b,max=0,cur;
    while(n--)
    {

    cin>>a>>b;
    cur+=b;
    cur-=a;
    if(cur>max)
    {
        max=cur;
    }

    }
    cout<<max<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1],b[n+1];
    while(n--)
    {
        for(int i=0;i<n;i++)
        {
            cin>>a[i]>>b[i];
            int r[n];

            for(int i=1;i<=n;i++)
            {
                r[0]=0
               r[i]=(r[i-1]-a[i])+b[i];
               int arr[n]=r[i];
                int res=sort(arr,arr+n);

            }
        }
    }
    cout<<res[n]<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a,b,max=0,cur;
    while(n--)
    {

    cin>a>>b;
    cur+=b;
    cur-=a;
    if(cur>max)
    {
        max=cur;
    }

    }
    cout<<max<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1],b[n+1];
    while(n--)
    {
        for(int i=0;i<n;i++)
        {
            cin>>a[i]>>b[i];
            int r[]={};
            r[0]=0
            for(int i=1;i<=n;i++)
            {
               r[i]=(r[i-1]-a[i])+b[i];
               int arr[n]=r[i];
                int res=sort(arr,n);

            }
        }
    }
    cout<<res[n]<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a,b,max=0,cur=0;
    while(n--)
    {

    cin>a>>b;
    cur+=b;
    cur-=a;
    if(cur>max)
    {
        max=cur;
    }

    }
    cout<<max<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1],b[n+1],res;
    while(n--)
    {
        for(int i=0;i<n;i++)
        {
            cin>>a[i]>>b[i];
            int r[n]={0};

            for(int i=1;i<=n;i++)
            {
                r[0]=0;
               r[i]=(r[i-1]-a[i])+b[i];
               int arr[n]=r[i];
                res=sort(arr,arr+n);

            }
        }
    }
    cout<<res[1]<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a,b,max=0,cur=0;
    while(n--)
    {

    cin>>a>>b;
    cur+=b;
    cur-=a;
    if(cur>max)
    {
        max=cur;
    }

    }
    cout<<max<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,max=0;
    cin>>n;
    while(n--)
    {
        for(int i=0;i<n;i++)

    {
        int a[n],b[n];
        cin>>a[i]>>b[i];
        while(b[i]-a[i]>max)
        {
            cout<<b[i]-a[i]<"\n";
        }
    }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1],b[n+1],res;
    while(n--)
    {
        for(int i=0;i<n;i++)
        {
            cin>>a[i]>>b[i];
            int r[]={};
            r[0]=0;
            for(int i=1;i<=n;i++)
            {
               r[i]=(r[i-1]-a[i])+b[i];
               int arr[n]=r[i];
               res=sort(arr,n);

            }
        }
    }
    cout<<res[n]<<"\n";
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    int max=0,max1=0;
    for(int i=0;i<n;i++){
        if(a[i]>max1){
            max1=a[i];
        }
    }
    for(int i=0;i<n;i++){
        if(b[i]>max){
            max=b[i];
        }
    }
    if(max1==max){
        cout<<max+1;
    }
    else{
        cout<<max+1;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    int m=0,c=0;
    for(int i=0;i<n;i++){
        c=c-a[i];
        c=c+b[i];
        if(c>m){
            m=c;
        }
    }
    cout<<m;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    int max=0;
    for(int i=0;i<n;i++){
        if(b[i]>max){
            max=b[i];
        }
    }
    cout<<max+1;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    int max=0,max1=0;
    for(int i=0;i<n;i++){
        if(a[i]>max1){
            max1=a[i];
        }
    }
    for(int i=0;i<n;i++){
        if(b[i]>max){
            max=b[i];
        }
    }
    if(max1==max){
        cout<<max;
    }
    else if(max1<max){
        cout<<max+1;
    }
    else
    {
        if(max1>max){
            int c=max+max1;
            cout<<c;
        }
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    int max=0,max1=0;
    for(int i=0;i<n;i++){
        if(a[i]>max1){
            max1=a[i];
        }
    }
    for(int i=0;i<n;i++){
        if(b[i]>max){
            max=b[i];
        }
    }
    if(max1==max){
        cout<<max;
    }
    else{
        cout<<max+1;
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    int max=0,max1=0;
    for(int i=0;i<n;i++){
        if(a[i]>max1){
            max1=a[i];
        }
    }
    for(int i=0;i<n;i++){
        if(b[i]>max){
            max=b[i];
        }
    }
    if(max==1 && max1==1){
        cout<<2;
    }
    else{
        if(max1==max){
            cout<<max;
        }
        else if(max1<max){
            cout<<max+1;
        }
        else
        {
            if(max1>max){
                int c=max+max1;
                cout<<c;
            }
        }
    }
    return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <map>
#include <algorithm>
#include <set>
#include <vector>
#include <bitset>
#include <cctype>

using namespace std;

int main()
{
     int n, e=0, d=0;
    cin >> n;
    int a[n], b[n], c[n];
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
        e += b[i] - a[i];
    }
    cout << d;
    return 0;
}


#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <map>
#include <algorithm>
#include <set>
#include <vector>
#include <bitset>
#include <cctype>

using namespace std;

int main()
{
     int n, d=0;
    cin >> n;
    int a[n], b[n], c[n];
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
        d += b[i] - a[i];
    }
    cout << d;
    return 0;
}


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	long n;
	cin >> n;
	int in[n], out[n];
	for(int i = 0; i< n;i++)
	{
		cin >> out[n] >> in[n];
	}
	int max = 0, curr=0;
	for(int i = 0; i<n;i++)
	{
		curr += in[i]-out[i];
		if(curr>max)
			max = curr;
	}
	cout << max;
	return 0;

}


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	long n;
	cin >> n;
	int in[n], out[n];
	for(int i = 0; i< n;i++)
	{
		cin >> out[n] >> in[n];
	}
	int max = 0, curr=0;
	for(int i = 0; i< n;i++)
	{
		curr += in[n];
		if(curr>max)
			max = curr;
		curr -= in[out];
	}
	cout << max;
	return 0;

}


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	long n;
	cin >> n;
	int in[n], out[n];
	for(int i = 0; i< n;i++)
	{
		cin >> out[n] >> in[n];
	}
	int max = 0, curr=0;
	for(int i = 0; i< n;i++)
	{
		curr += in[i];
		if(curr>max)
			max = curr;
		curr -= out[i];
	}
	cout << max;
	return 0;

}


#include <iostream>
#include <cctype>
#include <string>
using namespace std;

int main(){
    int n, e=0, d=0;
    cin >> n;
    int a[n], b[n], c[n];
    for(int i=0; i<n; i++){
        cin >> a[i] >> b[i];
        e += b[i] - a[i];
        if(e>d)
        d = e;
    }
    cout << d;
}


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
	long n;
	cin >> n;
	int in[n], out[n];
	for(int i = 0; i< n;i++)
	{
		cin >> out[i] >> in[i];
	}
	int max = 0, curr=0;
	for(int i = 0; i<n;i++)
	{
		curr += in[i]-out[i];
		if(curr>max)
			max = curr;
	}
	cout << max;
	return 0;

}


#include <iostream>
#include <string>
#include <cmath>
#include <sstream>
#include <map>
#include <algorithm>
#include <set>
#include <vector>
#include <bitset>
#include <cctype>

using namespace std;

int main()
{
     int n, e = 0, d=0;
    cin >> n;
    int a, b;
    for(int i=0; i<n; i++){
        cin >> a >> b;
        e += b - a;
        d = max(e,d);
    }
    cout << d;
    return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int aE[n],aI[n],a=0,sum=0;
    for(int j=0;j<n;j++)
    {
        cin>>aE[j]>>aI[j];
    }
    a=aI[0];
    for(int i=0;i<n;i++)
    {

       // cout<<"a:"<<a<<" ";
        sum=aI[i]-aE[i+1]+aI[i+1];
         //cout<<sum<<aI[i]<<aE[i+1]<<aI[i+1]<<endl;
        if(sum>a)
            {
                //cout<<"a1:"<<a<<" ";
                a=sum;
             //cout<<"a1:"<<a<<" ";
            }

        aI[i+1]=sum;
        sum=0;

    }
    cout<<a;

    return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int aE[100],aI[100],a=0,sum=0;
    for(int j=0;j<n;j++)
    {
        cin>>aE[j]>>aI[j];
    }
    a=aI[0];
    for(int i=0;i<n;i++)
    {

       // cout<<"a:"<<a<<" ";
       //if(i==n-1)
        //aE[i+1]=0aI[i+1]
        sum=aI[i]-aE[i+1]+aI[i+1];
         //cout<<sum<<aI[i]<<aE[i+1]<<aI[i+1]<<endl;
        if(sum>a)
            {
                //cout<<"a1:"<<a<<" ";
                a=sum;
             //cout<<"a1:"<<a<<" ";
            }

        aI[i+1]=sum;
        sum=0;

    }
    cout<<a;

    return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int aE[105],aI[10],a=0,sum=0;
    for(int j=0;j<n;j++)
    {
        cin>>aE[j]>>aI[j];
    }
    a=aI[0];
    for(int i=0;i<n-1;i++)
    {

       // cout<<"a:"<<a<<" ";
       //if(i==n-1)
        //aE[i+1]=0aI[i+1]
        sum=aI[i]-aE[i+1]+aI[i+1];
         //cout<<sum<<aI[i]<<aE[i+1]<<aI[i+1]<<endl;
        if(sum>a)
            {
                //cout<<"a1:"<<a<<" ";
                a=sum;
             //cout<<"a1:"<<a<<" ";
            }

        aI[i+1]=sum;
        sum=0;

    }
    cout<<a;

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int aE[n],aI[n],a=0,sum=0;
    for(int j=0; j<n; j++)
    {
        cin>>aE[j]>>aI[j];
    }
    a=aI[0];
    for(int i=0; i<n-1; i++)
    {
        sum=aI[i]-aE[i+1]+aI[i+1];
        aI[i+1]=sum;
        if(sum>a)
        {
            a=sum;
        }
    }
    cout<<a;

    return 0;
}


#include<iostream>
#include<cstring>
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int aE[105],aI[10],a=0,sum=0;
    for(int j=0; j<n; j++)
    {
        cin>>aE[j]>>aI[j];
    }
    a=aI[0];
    for(int i=0; i<n-1; i++)
    {
        sum=aI[i]-aE[i+1]+aI[i+1];
        aI[i+1]=sum;
        if(sum>a)
        {
            a=sum;
        }
    }
    cout<<a;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n , c = 0 , x = 0 ;
    cin >> n ;
    int arr[n][2] ;
    for (int i=0 ; i<n ; i++)
        {
            for (int j=0 ; j<2 ; j++)
                {
                    cin >> arr[i][j] ;
                }
        }
    for (int k=0 ; k<n ; k++)
        {
            if(k==n-1)
                {
                    break ;
                }
            for (int m=0 ; m<2 ; m++)
                {
                    if(m==1)
                        {
                            break ;
                        }
                    x = arr[k][m+1] - arr[k+1][m] + arr[k+1][m+1] ;
                    if (x>c)
                        {
                            c = x ;
                        }
                }
        }
    cout << c << endl ;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n , c = 0 , x = 0 ;
    cin >> n ;
    int arr[n][2] ;
    for (int i=0 ; i<n ; i++)
        {
            for (int j=0 ; j<2 ; j++)
                {
                    cin >> arr[i][j] ;
                }
        }
    for (int k=0 ; k<n ; k++)
        {
            if(k==n-1)
                {
                    break ;
                }
            if(arr[k][1] == arr[k+1][0] && arr[k+1][1] == 0)
               {
                   x = arr[k][0] ;
               }
            else
                {
                    x = arr[k][1] - arr[k+1][0] + arr[k+1][1] ;
                    arr[k+1][1] = x ;
                }
            if (x>c)
                {
                    c = x ;
                }
        }
    cout << c << endl ;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n , c = 0 , x = 0 ;
    cin >> n ;
    int arr[n][2] ;
    for (int i=0 ; i<n ; i++)
        {
            for (int j=0 ; j<2 ; j++)
                {
                    cin >> arr[i][j] ;
                }
        }
    for (int k=0 ; k<n ; k++)
        {
            if(k==n-1)
                {
                    break ;
                }
            if(arr[k][1] == arr[k+1][0] && arr[k+1][1] == 0)
               {
                   x = arr[k][1] ;
               }
            else
                {
                    x = arr[k][1] - arr[k+1][0] + arr[k+1][1] ;
                    arr[k+1][1] = x ;
                }
            if (x>c)
                {
                    c = x ;
                }
        }
    cout << c << endl ;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n , x = 0 ;
    cin >> n ;
    int arr[n][2] ;
    for (int i=0 ; i<n ; i++)
        {
            for (int j=0 ; j<2 ; j++)
                {
                    cin >> arr[i][j] ;
                }
        }
    int c = arr[0][1] ;
    for (int k=0 ; k<n ; k++)
        {
            if(k==n-1)
                {
                    break ;
                }
            if(arr[k][1] == arr[k+1][0] && arr[k+1][1] == 0)
               {
                   x = arr[k][1] ;
               }
            else
                {
                    x = arr[k][1] - arr[k+1][0] + arr[k+1][1] ;
                    arr[k+1][1] = x ;
                }
            if (x>c)
                {
                    c = x ;
                }
        }
    cout << c << endl ;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n , c = 0 , x = 0 ;
    cin >> n ;
    int arr[n][2] ;
    for (int i=0 ; i<n ; i++)
        {
            for (int j=0 ; j<2 ; j++)
                {
                    cin >> arr[i][j] ;
                }
        }
    for (int k=0 ; k<n ; k++)
        {
            if(k==n-1)
                {
                    break ;
                }
            if(arr[k][1] == arr[k+1][0] && arr[k+1][1] == 0)
               {
                   x = arr[k][0] ;
                   arr[k+1][1] = x ;
               }
            else
                {
                    x = arr[k][1] - arr[k+1][0] + arr[k+1][1] ;
                    arr[k+1][1] = x ;
                }
            if (x>c)
                {
                    c = x ;
                }
        }
    cout << c << endl ;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n , c = 0 , x = 0 ;
    cin >> n ;
    int arr[n][2] ;
    for (int i=0 ; i<n ; i++)
        {
            for (int j=0 ; j<2 ; j++)
                {
                    cin >> arr[i][j] ;
                }
        }
    for (int k=0 ; k<n ; k++)
        {
            if(k==n-1)
                {
                    break ;
                }
            if(arr[k][1] >= arr[k+1][0] && arr[k+1][1] == 0)
               {
                   x = arr[k][1] ;
               }
            else
                {
                    x = arr[k][1] - arr[k+1][0] + arr[k+1][1] ;
                    arr[k+1][1] = x ;
                }
            if (x>c)
                {
                    c = x ;
                }
        }
    cout << c << endl ;

    return 0;
}


#include <iostream>

using namespace std;

int main()
{
    int n , c = 0 , x = 0 ;
    cin >> n ;
    int arr[n][2] ;
    for (int i=0 ; i<n ; i++)
        {
            for (int j=0 ; j<2 ; j++)
                {
                    cin >> arr[i][j] ;
                }
        }
    for (int k=0 ; k<n ; k++)
        {
            if(k==n-1)
                {
                    break ;
                }
            x = arr[k][1] - arr[k+1][0] + arr[k+1][1] ;
            arr[k+1][1] = x ;
            if (x>c)
                {
                    c = x ;
                }
        }
    cout << c << endl ;

    return 0;
}


#include <iostream>
using namespace std;

int main()
{
int n,a,b,count=0,max=0;
cin>>n;
for(int i=0; i<n;i++)
{
  cin>>a>>b;
  int d=a-b;
  int r=count +d;
}
  if(r>max)
  {
    max=r;
  cout<<max;
  }
}


#include <iostream>
using namespace std;

int main()
{
int n,a,b,count=0,max=0;
cin>>n;
for(int i=0; i<n;i++)
{
  cin>>a>>b;
  int d=a-b;
  int r=count +d;
  if(r>max)
  {
    max=r;
  }
}
cout<<max;
}


#include <iostream>
using namespace std;

int main()
{
int n,a,b,count=0,max=0;
cin>>n;
for(int i=0; i<n;i++)
{
  cin>>a>>b;
  int d=b-a;
  count +=d;

  if(count>max)
   max=count;

  }
  cout<<max;
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n,0);
        for(int i = 0 ; i < n ; i++){
                cin >> a[i];
        }
        // a.push_back(a[0]);
        vector<int> out(n+1,0);
        out[0] = 1;
        bool flag = false;
        for(int i = 1 ; i < n ; i++){
                if(a[i] == a[i-1]){
                        out[i] = out[i-1];
                }
                else{
                        flag = true;
                        out[i] = (out[i-1])%2 + 1;
                }
        }
        if(!flag){
                cout << 1 << endl;
                out[n-1] = 1;
                for(int i = 0 ; i < n ; i++){
                        cout << out[i] << " ";
                }
                cout << endl;
                continue;
        }
        if(n%2 == 0){
                cout << 2 << endl;
                // out[n-1] = (out[n-2])%2 + 1;
                for(int i = 0 ; i < n ; i++){
                        cout << out[i] << " ";
                }
                cout << endl;
                continue;

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

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

        }

    }
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n,0);
        for(int i = 0 ; i < n ; i++){
                cin >> a[i];
        }
        // a.push_back(a[0]);
        vector<int> out(n+1,0);
        out[0] = 1;
        bool flag = false;
        for(int i = 1 ; i < n ; i++){
                if(a[i] == a[i-1]){
                        out[i] = out[i-1];
                }
                else{
                        flag = true;
                        out[i] = (out[i-1])%2 + 1;
                }
        }
        if(!flag){
                cout << 1 << endl;
                out[n-1] = 1;
                for(int i = 0 ; i < n ; i++){
                        cout << out[i] << " ";
                }
                cout << endl;
                continue;
        }
        if(n%2 == 0){
                cout << 2 << endl;
                // out[n-1] = (out[n-2])%2 + 1;
                for(int i = 0 ; i < n ; i++){
                        cout << out[i] << " ";
                }
                cout << endl;
                continue;

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

                        for(int i = 0 ; i < n ; i++){
                        cout << out[i] << " ";
                        }
                        cout << endl;
                        continue;
                }

        }

    }
}


    #include <bits/stdc++.h>
    using namespace std;

    void solve(){
    	int n;
    	cin >> n;
    	vector<int> a(n);
    	for(int i = 0; i < n; i++) cin >> a[i];
    	bool same = true;
    	for(int i = 0; i < n; i++) if(a[i] != a[0]) same = false;
    	if(same){
    		cout << 1 << '\n';
    		for(int i = 0; i < n; i++) cout << 1 << ' ';
    		cout << '\n';
    		return;
    	}
    	if(n % 2 == 0){
    		cout << 2 << '\n';
    		for(int i = 0; i < n; i++){
    			cout << 1 + (i & 1) << ' ';
    		}
    		cout << '\n';
    		return;
    	}
    	for(int i = 0; i < n; i++){
    		if(a[i] == a[(i+1) % n]){
    			cout << 2 << '\n';
    			for(int j = 0; j < n; j++){
    				cout << 1 + (1 & ((j - i - 1 + n) % n)) << ' ';
    			}
    			cout << '\n';
    			return;
    		}
    	}
    	cout << 3 << '\n';
    	cout << 3 << ' ';
    	for(int i = 1; i < n; i++){
    		cout << 1 + (i & 1) << ' ';
    	}
    	cout << '\n';
    }

    int main(){
    	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    	int T;
    	cin >> T;
    	while(T--) solve();
    }


#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n,0);
        for(int i = 0 ; i < n ; i++){
                cin >> a[i];
        }
        // a.push_back(a[0]);
        vector<int> out(n+1,0);
        out[0] = 1;
        // out[n] = 1;
        bool flag = false;
        for(int i = 1 ; i < n-1 ; i++){
                if(a[i] == a[i-1]){
                        out[i] = out[i-1];
                }
                else
                {
                        out[i] = (out[i-1])%2 + 1;
                        flag = true;
                }
        }
        if(a[n-1] != a[n-2] && a[n-1] != a[0]){
                out[n-1] = 3;
            cout << 3 << endl;
        }
        else if(a[n-1] != a[n-2] && a[n-1] == a[0]){
                out[n-1] = out[0];
                cout << 2 << endl;
        }
        else if(a[n-1] == a[n-2] && a[n-1] != a[0]){
                out[n-1] = out[n-2];
                cout << 2 << endl;
        }
        else{
                out[n-1] = out[0];
                if(flag){
                    cout << 2 << endl;
                }
                else
                {
                    cout << 1 << endl;
                }
        }

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


#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n,0);
        for(int i = 0 ; i < n ; i++){
                cin >> a[i];
        }
        // a.push_back(a[0]);
        vector<int> out(n+1,0);
        out[0] = 1;
        bool flag = false;
        for(int i = 1 ; i < n ; i++){
                if(a[i] == a[i-1]){
                        out[i] = out[i-1];
                }
                else{
                        flag = true;
                        out[i] = (out[i-1])%2 + 1;
                }
        }
        if(!flag){
                cout << 1 << endl;
                out[n-1] = 1;
                for(int i = 0 ; i < n ; i++){
                        cout << out[i] << " ";
                }
                cout << endl;
                continue;
        }
        if(n%2 == 0){
                cout << 2 << endl;
                // out[n-1] = (out[n-2])%2 + 1;
                for(int i = 0 ; i < n ; i++){
                        cout << i%2 + 1 << " ";
                }
                cout << endl;
                continue;

        }

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

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

        }

    }
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n,0);
        for(int i = 0 ; i < n ; i++){
                cin >> a[i];
        }
        a.push_back(a[0]);
        vector<int> out(n+1,0);
        out[0] = 1;
        out[n] = 1;
        bool flag = false;
        for(int i = 1 ; i < n-1 ; i++){
                if(a[i] == a[i-1]){
                        out[i] = out[i-1];
                }
                else
                {
                        out[i] = (out[i-1])%2 + 1;
                        flag = true;
                }
        }
        if(a[n-1] != a[n-2] && a[n-1] != a[n]){
                out[n-1] = 3;
            cout << 3 << endl;
        }
        else if(a[n-1] != a[n-2] && a[n-1] == a[n]){
                out[n-1] = out[n];
                cout << 2 << endl;
        }
        else if(a[n-1] == a[n-2] && a[n-1] != a[n]){
                out[n-1] = out[n-2];
                cout << 2 << endl;
        }
        else{
                out[n-1] = out[n];
                if(flag){
                    cout << 2 << endl;
                }
                else
                {
                    cout << 1 << endl;
                }
        }

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


#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n,0);
        for(int i = 0 ; i < n ; i++){
                cin >> a[i];
        }
        // a.push_back(a[0]);
        vector<int> out(n+1,0);
        out[0] = 1;
        bool flag = false;
        if(n%2 == 0){
                cout << 2 << endl;
                // out[n-1] = (out[n-2])%2 + 1;
                for(int i = 0 ; i < n ; i++){
                        cout << i%2 + 1 << " ";
                }
                cout << endl;
                continue;

        }
        for(int i = 1 ; i < n ; i++){
                if(a[i] == a[i-1]){
                        out[i] = out[i-1];
                }
                else{
                        flag = true;
                        out[i] = (out[i-1])%2 + 1;
                }
        }
        if(!flag){
                cout << 1 << endl;
                out[n-1] = 1;
                for(int i = 0 ; i < n ; i++){
                        cout << out[i] << " ";
                }
                cout << endl;
                continue;
        }

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

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

        }

    }
}


#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin >> t;
    while(t--){
        int n;
        cin >> n;
        vector<int> a(n,0);
        for(int i = 0 ; i < n ; i++){
                cin >> a[i];
        }
        // a.push_back(a[0]);
        vector<int> out(n+1,0);
        out[0] = 1;
        bool flag = false;
        if(n%2 == 0){
                cout << 2 << endl;
                // out[n-1] = (out[n-2])%2 + 1;
                for(int i = 0 ; i < n ; i++){
                        cout << i%2 + 1 << " ";
                }
                cout << endl;
                continue;

        }
        for(int i = 1 ; i < n ; i++){
                if(a[i] == a[i-1]){
                        out[i] = out[i-1];
                }
                else{
                        flag = true;
                        out[i] = (out[i-1])%2 + 1;
                }
        }
        if(!flag){
                cout << 1 << endl;
                out[n-1] = 1;
                for(int i = 0 ; i < n ; i++){
                        cout << out[i] << " ";
                }
                cout << endl;
                continue;
        }

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

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

        }

    }
}


// MD. Ashiqur Rahman
#include<bits/stdc++.h>
using namespace std;

#define         ll         long long
#define         pb         push_back
#define         scn(x)     scanf("%d",&x)
#define         scnl(x)    scanf("%lld",&x)
#define         prnt(x)    printf("%d\n",x)
#define         prntl(x)   printf("%lld\n",x)
#define         prii       pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         prll       pair<ll,ll>
#define         vctri      vector<int>
#define         vctrl      vector<ll>
#define         vctrd      vector<double,double>
#define         all(a)     (a).begin(),(a).end()
#define         rall(a)    (a).rbegin(),(a).rend()
#define         F          first
#define         S          second
#define         mp         make_pair
#define         ftc(x)     cerr << #x << ": " << x << " " << '\n';
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define         fast       ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         sqr(a)     ((a)*(a))
#define         memset(x,v) memset(x, v, sizeof(x))
#define         ask         '\n'
#define         negmod(x,y) ((x % y) + y) % y

vector<bool> isPrime(10000010, true);
inline void seivePrime(ll L, ll R) { ll lim = sqrt(R);for (ll i = 2; i <= lim; ++i){
        for (ll j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;}if (L == 1)isPrime[0] = false;}
inline ll chckPrime(ll L,ll prme){return isPrime[prme - L];}
inline ll cntPrime(ll L,ll R){return count(isPrime.begin(),isPrime.begin() + R - L + 1,true);}

int main(){
    fast;
    int t;
    cin >> t;
    while(t --){
        int n,x;
        cin >> n;
        int ar[n],sol[n],br[n];
        for(int i = 0;i < n;i ++)
            cin >> ar[i],br[i] = ar[i];
        sort(br,br + n);
        if(br[0] == br[n - 1]){
            cout << 1 << "\n";
            for(int i = 0;i < n;i ++)
                cout << "1 ";
            cout << "\n";
            continue;
        }
        sol[0] = 0;
        for(int i = 1;i + 1 < n;i ++){
            if(ar[i] != ar[i - 1])
                sol[i] = sol[i - 1] ^ 1;
            else
                sol[i] = sol[i - 1];
        }
        int a = n - 1,b = n - 2,c = 0;
        if(ar[a] != ar[b] && ar[a] != ar[c]){
            x = 3;
            sol[a] = 2;
        }
        else{
            x = 2;
            if(ar[b] == ar[a])
                sol[a] = sol[0] ^ 1;
            else
                sol[a] = sol[b] ^ 1;
        }
        cout << x << "\n";
        for(int i = 0;i < n;i ++)
            cout << sol[i] + 1 << " ";
        cout << "\n";
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int q;
    cin >> q;
    while(q --){
        int n;
        cin >> n;
        int ar[n + 10];
        set<int> s;
        for(int i = 0;i < n;i ++){
            cin >> ar[i];
            s.insert(ar[i]);
        }
        int flag = 0;
        if(s.size() > 1 && n % 2 ==0){
            cout << "2\n";
            for(int i = 0;i < n;i ++){
                if(i % 2)
                    cout << "2 ";
                else
                    cout << "1 ";
            }
            cout << "\n";
        }
        else if(s.size() == 1){
            cout << "1\n";
            for(int i = 0;i < n;i ++)
                cout << "1 ";
            cout << "\n";
        }
        else{
            for(int i = 1;i < n; i++){
                if(ar[i] == ar[i - 1]){
                    flag = i;
                    break;
                }
            }
            if(flag){
                cout << "2\n";
                int x = 2;
                for(int i = 0;i < n;i ++){
                    if(i == flag)
                        cout << x << " ";
                    else{
                        (x >= 2) ? -- x : ++ x;
                        cout << x << " ";
                    }
                }
            }
            else{
                cout << "3\n";
                for(int i = 0;i < n - 1;i ++)
                    if(i % 2)
                        cout << "2 ";
                    else
                        cout << "1 ";
                cout << "3";
            }
            cout << "\n";
        }

    }

    return 0;
}


// MD. Ashiqur Rahman
#include<bits/stdc++.h>
using namespace std;

#define         ll         long long
#define         pb         push_back
#define         scn(x)     scanf("%d",&x)
#define         scnl(x)    scanf("%lld",&x)
#define         prnt(x)    printf("%d\n",x)
#define         prntl(x)   printf("%lld\n",x)
#define         prii       pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         prll       pair<ll,ll>
#define         vctri      vector<int>
#define         vctrl      vector<ll>
#define         vctrd      vector<double,double>
#define         all(a)     (a).begin(),(a).end()
#define         rall(a)    (a).rbegin(),(a).rend()
#define         F          first
#define         S          second
#define         mp         make_pair
#define         ftc(x)     cerr << #x << ": " << x << " " << '\n';
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define         fast       ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         sqr(a)     ((a)*(a))
#define         memset(x,v) memset(x, v, sizeof(x))
#define         ask         '\n'
#define         negmod(x,y) ((x % y) + y) % y

vector<bool> isPrime(10000010, true);
inline void seivePrime(ll L, ll R) { ll lim = sqrt(R);for (ll i = 2; i <= lim; ++i){
        for (ll j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;}if (L == 1)isPrime[0] = false;}
inline ll chckPrime(ll L,ll prme){return isPrime[prme - L];}
inline ll cntPrime(ll L,ll R){return count(isPrime.begin(),isPrime.begin() + R - L + 1,true);}

int main(){
    fast;
    int t;
    cin >> t;
    while(t --){
        int n,x;
        cin >> n;
        int ar[n],sol[n],br[n];
        for(int i = 0;i < n;i ++)
            cin >> ar[i],br[i] = ar[i];
        sort(br,br + n);
        if(br[0] == br[n - 1]){
            cout << 1 << "\n";
            for(int i = 0;i < n;i ++)
                cout << "1 ";
            cout << "\n";
            continue;
        }
        sol[0] = 0;
        for(int i = 1;i + 1 < n;i ++){
            if(ar[i])
                sol[i] = sol[i - 1] ^ 1;
        }
        int a = n - 1,b = n - 2,c = 0;
        if(ar[a] != ar[b] && ar[a] != ar[c]){
            if(sol[0] == sol[b]){
                x = 2;
                sol[a] = sol[0] ^ 1;
            }
            else if(ar[0] == ar[b]){
                x = 2;
                sol[a] = sol[0] ^ 1;
            }
            else{
                x = 3;
                sol[a] = 2;
            }
        }
        else{
            x = 2;
            if(ar[b] == ar[a])
                sol[a] = sol[0] ^ 1;
            else
                sol[a] = sol[b] ^ 1;
        }
        cout << x << "\n";
        for(int i = 0;i < n;i ++)
            cout << sol[i] + 1 << " ";
        cout << "\n";
    }

    return 0;
}


// MD. Ashiqur Rahman
#include<bits/stdc++.h>
using namespace std;

#define         ll         long long
#define         pb         push_back
#define         scn(x)     scanf("%d",&x)
#define         scnl(x)    scanf("%lld",&x)
#define         prnt(x)    printf("%d\n",x)
#define         prntl(x)   printf("%lld\n",x)
#define         prii       pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         prll       pair<ll,ll>
#define         vctri      vector<int>
#define         vctrl      vector<ll>
#define         vctrd      vector<double,double>
#define         all(a)     (a).begin(),(a).end()
#define         rall(a)    (a).rbegin(),(a).rend()
#define         F          first
#define         S          second
#define         mp         make_pair
#define         ftc(x)     cerr << #x << ": " << x << " " << '\n';
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define         fast       ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         sqr(a)     ((a)*(a))
#define         memset(x,v) memset(x, v, sizeof(x))
#define         ask         '\n'
#define         negmod(x,y) ((x % y) + y) % y

vector<bool> isPrime(10000010, true);
inline void seivePrime(ll L, ll R) { ll lim = sqrt(R);for (ll i = 2; i <= lim; ++i){
        for (ll j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;}if (L == 1)isPrime[0] = false;}
inline ll chckPrime(ll L,ll prme){return isPrime[prme - L];}
inline ll cntPrime(ll L,ll R){return count(isPrime.begin(),isPrime.begin() + R - L + 1,true);}

int main(){
    fast;
    int t;
    cin >> t;
    while(t --){
        int n,x;
        cin >> n;
        int ar[n],sol[n],br[n];
        for(int i = 0;i < n;i ++)
            cin >> ar[i],br[i] = ar[i];
        sort(br,br + n);
        if(br[0] == br[n - 1]){
            cout << 1 << "\n";
            for(int i = 0;i < n;i ++)
                cout << "1 ";
            cout << "\n";
            continue;
        }
        sol[0] = 0;
        for(int i = 1;i + 1 < n;i ++){
            if(ar[i] != ar[i - 1])
                sol[i] = sol[i - 1] ^ 1;
            else
                sol[i] = sol[i - 1];
        }
        int a = n - 1,b = n - 2,c = 0;
        if(ar[a] != ar[b] && ar[a] != ar[c]){
            if(sol[0] == sol[b]){
                x = 2;
                sol[a] = sol[0] ^ 1;
            }
            else{
            x = 3;
            sol[a] = 2;
            }
        }
        else{
            x = 2;
            if(ar[b] == ar[a])
                sol[a] = sol[0] ^ 1;
            else
                sol[a] = sol[b] ^ 1;
        }
        cout << x << "\n";
        for(int i = 0;i < n;i ++)
            cout << sol[i] + 1 << " ";
        cout << "\n";
    }

    return 0;
}


// MD. Ashiqur Rahman
#include<bits/stdc++.h>
using namespace std;

#define         ll         long long
#define         pb         push_back
#define         scn(x)     scanf("%d",&x)
#define         scnl(x)    scanf("%lld",&x)
#define         prnt(x)    printf("%d\n",x)
#define         prntl(x)   printf("%lld\n",x)
#define         prii       pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         prll       pair<ll,ll>
#define         vctri      vector<int>
#define         vctrl      vector<ll>
#define         vctrd      vector<double,double>
#define         all(a)     (a).begin(),(a).end()
#define         rall(a)    (a).rbegin(),(a).rend()
#define         F          first
#define         S          second
#define         mp         make_pair
#define         ftc(x)     cerr << #x << ": " << x << " " << '\n';
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define         fast       ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         sqr(a)     ((a)*(a))
#define         memset(x,v) memset(x, v, sizeof(x))
#define         ask         '\n'
#define         negmod(x,y) ((x % y) + y) % y

vector<bool> isPrime(10000010, true);
inline void seivePrime(ll L, ll R) { ll lim = sqrt(R);for (ll i = 2; i <= lim; ++i){
        for (ll j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;}if (L == 1)isPrime[0] = false;}
inline ll chckPrime(ll L,ll prme){return isPrime[prme - L];}
inline ll cntPrime(ll L,ll R){return count(isPrime.begin(),isPrime.begin() + R - L + 1,true);}

int main(){
    fast;
    int t;
    cin >> t;
    while(t --){
        int n,x;
        cin >> n;
        int ar[n],sol[n],br[n],cr[n];
        for(int i = 0;i < n;i ++)
            cin >> ar[i],br[i] = ar[i];
        sort(br,br + n);
        if(br[0] == br[n - 1]){
            cout << "1\n";
            for(int i = 0;i < n;i ++)
                cout << "1 ";
            cout << "\n";
        }
        else if(n % 2 == 0){
            cout << "2\n";
            for(int i = 1;i <= n;i ++)
                if(i & 1)
                    cout << "1 ";
                else
                    cout << "2 ";
            cout << "\n";
        }
        else{
            int f = -1;
            for(int i = 1;i < n;i ++){
                if(ar[i] == ar[i - 1]){
                    f = i;
                    break;
                }
            }
            if(f == -1){
                cout << "3\n";
                for(int i = 1;i < n;i ++)
                    if(i & 1)
                        cout << "1 ";
                    else
                        cout << "2 ";
                cout << "3\n";
            }
            else{
                int x = 0;
                cout << "2\n";
                for(int i = 1;i <= n;i ++){
                    if(i == f){
                        if(!x)
                            x = 1,cout << "1 1 ";
                        else if(x == 1)
                            x = 2,cout << "2 2 ";
                        else
                            x = 1,cout << "1 1 ";
                        i ++;
                        continue;
                    }
                    if(x == 0 || x == 2)
                        x = 1;
                    else if(x == 1)
                        x = 2;
                    cout << x << " ";
                }
                cout << "\n";
            }
        }

    }

    return 0;
}


// MD. Ashiqur Rahman
#include<bits/stdc++.h>
using namespace std;

#define         ll         long long
#define         pb         push_back
#define         scn(x)     scanf("%d",&x)
#define         scnl(x)    scanf("%lld",&x)
#define         prnt(x)    printf("%d\n",x)
#define         prntl(x)   printf("%lld\n",x)
#define         prii       pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         prll       pair<ll,ll>
#define         vctri      vector<int>
#define         vctrl      vector<ll>
#define         vctrd      vector<double,double>
#define         all(a)     (a).begin(),(a).end()
#define         rall(a)    (a).rbegin(),(a).rend()
#define         F          first
#define         S          second
#define         mp         make_pair
#define         ftc(x)     cerr << #x << ": " << x << " " << '\n';
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define         fast       ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         sqr(a)     ((a)*(a))
#define         memset(x,v) memset(x, v, sizeof(x))
#define         ask         '\n'
#define         negmod(x,y) ((x % y) + y) % y

vector<bool> isPrime(10000010, true);
inline void seivePrime(ll L, ll R) { ll lim = sqrt(R);for (ll i = 2; i <= lim; ++i){
        for (ll j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;}if (L == 1)isPrime[0] = false;}
inline ll chckPrime(ll L,ll prme){return isPrime[prme - L];}
inline ll cntPrime(ll L,ll R){return count(isPrime.begin(),isPrime.begin() + R - L + 1,true);}

int main(){
    fast;
    int t;
    cin >> t;
    while(t --){
        int n,x;
        cin >> n;
        int ar[n],sol[n],br[n],cr[n];
        for(int i = 0;i < n;i ++)
            cin >> ar[i],br[i] = ar[i];
        sort(br,br + n);
        if(br[0] == br[n - 1]){
            cout << "1\n";
            for(int i = 0;i < n;i ++)
                cout << "1 ";
            cout << "\n";
        }
        else if(n % 2 == 0 || ar[0] == ar[n - 1]){
            cout << "2\n";
            for(int i = 1;i <= n;i ++)
                if(i & 1)
                    cout << "1 ";
                else
                    cout << "2 ";
            cout << "\n";
        }
        else{
            int f = -1;
            for(int i = 1;i < n;i ++){
                if(ar[i] == ar[i - 1]){
                    f = i;
                    break;
                }
            }
            if(f == -1){
                cout << "3\n";
                for(int i = 1;i < n;i ++)
                    if(i & 1)
                        cout << "1 ";
                    else
                        cout << "2 ";
                cout << "3\n";
            }
            else{
                int x = 0;
                cout << "2\n";
                for(int i = 1;i <= n;i ++){
                    if(i == f){
                        if(!x)
                            x = 1,cout << "1 1 ";
                        else if(x == 1)
                            x = 2,cout << "2 2 ";
                        else
                            x = 1,cout << "1 1 ";
                        i ++;
                        continue;
                    }
                    if(x == 0 || x == 2)
                        x = 1;
                    else if(x == 1)
                        x = 2;
                    cout << x << " ";
                }
                cout << "\n";
            }
        }

    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int q;
    cin >> q;
    while(q --){
        int n;
        cin >> n;
        int ar[n];
        set<int> s;
        for(int i = 0;i < n;i ++){
            cin >> ar[i];
            s.insert(ar[i]);
        }
        map<int,int> sol;
        int ans[n];
        int k = s.size();
        cout << k << "\n";
        int x = 1;
        for(int i = 0;i < n;i ++){
            if(sol[ar[i]] == 0){
                sol[ar[i]] = x;
                ans[i] = x ++;
            }
            else{
                ans[i] = sol[ar[i]];
            }
        }
        for(int i = 0;i < n;i ++)
            cout << ans[i] << " ";
        cout << "\n";
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int q;
    cin >> q;
    while(q --){
        int n;
        cin >> n;
        int ar[n + 10];
        set<int> s;
        for(int i = 0;i < n;i ++){
            cin >> ar[i];
            s.insert(ar[i]);
        }
        int flag = 0;
        if(s.size() > 1 && n % 2 ==0){
            cout << "2\n";
            for(int i = 0;i < n;i ++){
                if(i % 2)
                    cout << "2 ";
                else
                    cout << "1 ";
            }
            cout << "\n";
        }
        else if(s.size() == 1){
            cout << "1\n";
            for(int i = 0;i < n;i ++)
                cout << "1 ";
            cout << "\n";
        }
        else{
            if(ar[ n - 1] == ar[0]){
                cout << "2\n";
                for(int i = 0;i < n - 1;i ++)
                    if(i % 2)
                        cout << "2 ";
                    else
                        cout << "1 ";
                cout << "1\n";
            }
            else{
                for(int i = 1;i < n; i++){
                    if(ar[i] == ar[i - 1]){
                        flag = i;
                    }
                }
                if(flag){
                    cout << "2\n";
                    int x = 2;
                    for(int i = 0;i < n;i ++){
                        if(i == flag)
                            cout << x << " ";
                        else{
                            (x >= 2) ? -- x : ++ x;
                            cout << x << " ";
                        }
                    }
                }
                else{
                    cout << "3\n";
                        for(int i = 0;i < n - 1;i ++)
                            if(i % 2)
                                cout << "2 ";
                            else
                                cout << "1 ";
                    cout << "3";
                }
                cout << "\n";
            }
        }

    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int q;
    cin >> q;
    while(q --){
        int n;
        cin >> n;
        int ar[n + 10];
        set<int> s;
        for(int i = 0;i < n;i ++){
            cin >> ar[i];
            s.insert(ar[i]);
        }
        if(s.size() > 1 && n % 2 ==0){
            cout << "2\n";
            for(int i = 0;i < n;i ++){
                if(i % 2)
                    cout << "2 ";
                else
                    cout << "1 ";
            }
            cout << "\n";
        }
        else if(s.size() == 1){
            cout << "1\n";
            for(int i = 0;i < n;i ++)
                cout << "1 ";
            cout << "\n";
        }
        else if(ar[n - 1] != ar[n - 2]){
            cout << "3\n";
            for(int i = 0;i < n - 1;i ++){
                if(i % 2)
                    cout << "2 ";
                else
                    cout << "1 ";
            }
            cout << "3\n";
        }
        else{
            cout << "2\n";
            for(int i = 0;i < n - 1; i++){
                if(i % 2)
                    cout << "2 ";
                else
                    cout << "1 ";
            }
            cout << "2\n";
        }

    }

    return 0;
}


// MD. Ashiqur Rahman
#include<bits/stdc++.h>
using namespace std;

#define         ll         long long
#define         pb         push_back
#define         scn(x)     scanf("%d",&x)
#define         scnl(x)    scanf("%lld",&x)
#define         prnt(x)    printf("%d\n",x)
#define         prntl(x)   printf("%lld\n",x)
#define         prii       pair<int,int>
#define         mapii      map<int,int>
#define         mapll      map<ll,ll>
#define         mapci      map<char,int>
#define         mapcl      map<char,ll>
#define         mapsi      map<string,int>
#define         mapsl      map<string,ll>
#define         prll       pair<ll,ll>
#define         vctri      vector<int>
#define         vctrl      vector<ll>
#define         vctrd      vector<double,double>
#define         all(a)     (a).begin(),(a).end()
#define         rall(a)    (a).rbegin(),(a).rend()
#define         F          first
#define         S          second
#define         mp         make_pair
#define         ftc(x)     cerr << #x << ": " << x << " " << '\n';
#define         PI         acos(-1)
#define         lcm(a,b)   ((a*b)/__gcd(a,b))
#define         fast       ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define         sqr(a)     ((a)*(a))
#define         memset(x,v) memset(x, v, sizeof(x))
#define         ask         '\n'
#define         negmod(x,y) ((x % y) + y) % y

vector<bool> isPrime(10000010, true);
inline void seivePrime(ll L, ll R) { ll lim = sqrt(R);for (ll i = 2; i <= lim; ++i){
        for (ll j = max(i * i, (L + i - 1) / i * i); j <= R; j += i)
            isPrime[j - L] = false;}if (L == 1)isPrime[0] = false;}
inline ll chckPrime(ll L,ll prme){return isPrime[prme - L];}
inline ll cntPrime(ll L,ll R){return count(isPrime.begin(),isPrime.begin() + R - L + 1,true);}

int main(){
    fast;
    int t;
    cin >> t;
    while(t --){
        int n,x;
        cin >> n;
        int ar[n],sol[n],br[n];
        for(int i = 0;i < n;i ++)
            cin >> ar[i],br[i] = ar[i];
        sort(br,br + n);
        if(br[0] == br[n - 1]){
            cout << 1 << "\n";
            for(int i = 0;i < n;i ++)
                cout << "1 ";
            cout << "\n";
            continue;
        }
        sol[0] = 0;
        for(int i = 1;i + 1 < n;i ++){
            if(ar[i] != ar[i - 1])
                sol[i] = sol[i - 1] ^ 1;
            else
                sol[i] = sol[i - 1];
        }
        int a = n - 1,b = n - 2,c = 0;
        if(ar[a] != ar[b] && ar[a] != ar[c]){
            if(sol[0] == sol[b]){
                x = 2;
                sol[a] = sol[0] ^ 1;
            }
            else if(ar[0] == ar[b]){
                x = 2;
                sol[a] = sol[0] ^ 1;
            }
            else{
                x = 3;
                sol[a] = 2;
            }
        }
        else{
            x = 2;
            if(ar[b] == ar[a])
                sol[a] = sol[0] ^ 1;
            else
                sol[a] = sol[b] ^ 1;
        }
        cout << x << "\n";
        for(int i = 0;i < n;i ++)
            cout << sol[i] + 1 << " ";
        cout << "\n";
    }

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main(){
    int q;
    cin >> q;
    while(q --){
        int n;
        cin >> n;
        int ar[n + 10];
        set<int> s;
        for(int i = 0;i < n;i ++){
            cin >> ar[i];
            s.insert(ar[i]);
        }
        if(s.size() > 1 && n % 2 ==0){
            cout << "2\n";
            for(int i = 0;i < n;i ++){
                if(i % 2)
                    cout << "2 ";
                else
                    cout << "1 ";
            }
            cout << "\n";
        }
        else if(s.size() == 1){
            cout << "1\n";
            for(int i = 0;i < n;i ++)
                cout << "1 ";
            cout << "\n";
        }
        else if(ar[n - 1] != ar[n - 2]){
            cout << "3\n";
            for(int i = 0;i < n - 1;i ++){
                if(i % 2)
                    cout << "2 ";
                else
                    cout << "1 ";
            }
            cout << "3\n";
        }
        else{
            cout << "2\n";
            for(int i = 0;i < n; i++){
                if(i % 2)
                    cout << "2 ";
                else
                    cout << "1 ";
            }
            cout << "\n";
        }

    }

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define M (ll)(1e9+7)
#define ll long long
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        vector <ll> in(n);
        for(ll i=0;i<n;i++)
        {
            cin>>in[i];
        }
        vector <ll> color(n,-1);
        color[0]=1;
        ll k=1;
        for(ll i=1;i<n;i++)
        {
            if((in[i]==in[i-1])&&(color[(i+1)%n]==-1))
            {
                color[i]=color[i-1];
            }
            else if((in[i]!=in[i-1])&&(color[(i+1)%n]==-1))
            {
                k=2;
                color[i]=1+(color[i-1])%2;
            }
            else
            {
                if((in[i]==in[i-1])&&(in[i]==in[i+1]))
                {
                    color[i]=color[i-1];
                }
                else if((in[i]!=in[i-1])&&(in[i]!=in[i+1]))
                {
                    if(color[i-1]==color[(i+1)%n])
                    {
                        if(k==1)
                            k++;
                        color[i]=1+(color[i-1])%2;
                    }
                    else
                    {
                        k=3;
                        color[i]=3;
                    }

                }
                else
                {
                        if(color[i-1]==color[(i+1)%n])
                        {
                            k=2;
                            color[i]=1+color[i-1]%2;
                        }
                        else
                        {
                            if(in[i]==in[i-1])
                                color[i]=color[i-1];
                            else
                            {
                                color[i]=color[(i+1)%n];
                            }
                        }
                }

            }

        }
        cout<<k<<endl;
        for(ll i=0;i<n;i++)
            cout<<color[i]<<" ";
        cout<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define M (ll)(1e9+7)
#define ll long long
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        vector <ll> in(n);
        for(ll i=0;i<n;i++)
        {
            cin>>in[i];
        }
        vector <ll> color(n,-1);
        color[0]=1;
        ll k=1;
        for(ll i=1;i<n;i++)
        {
            if((in[i]==in[i-1])&&(color[(i+1)%n]==-1))
            {
                color[i]=color[i-1];
            }
            else if((in[i]!=in[i-1])&&(color[(i+1)%n]==-1))
            {
                k=2;
                color[i]=1+(color[i-1])%2;
            }
            else
            {
                if((in[i]==in[i-1])&&(in[i]==in[(i+1)%n]))
                {
                    color[i]=color[i-1];
                }
                else if((in[i]!=in[i-1])&&(in[i]!=in[(i+1)%n]))
                {
                    if(color[i-1]==color[(i+1)%n])
                    {
                        if(k==1)
                            k++;
                        color[i]=1+(color[i-1])%2;
                    }
                    else
                    {
                        if(i>=2)
                        {
                            if(in[i-1]!=in[i-2])
                            {
                                k=3;
                                color[i]=3;
                            }
                            else
                            {
                                k=2;
                                in[i-1]=1+in[i-2]%2;
                                in[i]=1+in[i-1]%2;
                            }
                        }
                        else
                    }

                }
                else
                {
                        if(color[i-1]==color[(i+1)%n])
                        {
                            k=2;
                            color[i]=1+color[i-1]%2;
                        }
                        else
                        {
                            if(in[i]==in[i-1])
                                color[i]=color[i-1];
                            else
                            {
                                color[i]=color[(i+1)%n];
                            }
                        }
                }

            }

        }
        cout<<k<<endl;
        for(ll i=0;i<n;i++)
            cout<<color[i]<<" ";
        cout<<endl;
    }
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define inarr(i,arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(i,arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<' ';
#define swap(a,b,t) {t=a;a=b;b=t;}
#define ve vector
#define sz(a) (int)((a).size())
#define fi first
#define se second
#define pa pair
#define fastio  {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define ll long long int
#define fr(i, a, b); for (int i = a; i < b; i++)
#define frn(i, a, b); for (int i = a; i > b; i--)
#define mk make_pair
#define setvector(vname,value,size); for(int i=0;i<size;i++)vname[i]=value;
const ll inf = 1e18;
int main()
{
    //fastio
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ve <ll> in(n);
        inarr(i,in,n);
        ll k=1;
        fr(i,1,n)
        {
            if(in[i]!=in[i-1])
                k=2;
        }
        if(k==1)
        {
            cout<<1<<endl;
            fr(i,0,n)
            {
                cout<<"1 ";
            }
            cout<<endl;
            return 0;
        }
        if(n%2)
        {

            cout<<2<<endl;
            fr(i,0,n/2)
            {
                cout<<"1 2 ";
            }
            cout<<endl;
        }
        else
        {
            k=3;
            ll j=-1;
            fr(i,1,n)
            {
                if(in[i]==in[i-1])
                {
                    j=i;
                    k=2;
                }
            }
            if(k==3)
            {
                cout<<k<<endl;
                fr(i,0,n-1)
                {
                    cout<<1+i%2<<" ";
                }
                cout<<3<<endl;
            }
            else
            {
                cout<<2<<endl;
                fr(i,0,j)
                {
                    cout<<1+i%2<<" ";
                }
                fr(i,j,n)
                {
                    cout<<1+(i-1)%2<<" ";
                }
                cout<<endl;
            }

        }

    }
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define inarr(i,arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(i,arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<' ';
#define swap(a,b,t) {t=a;a=b;b=t;}
#define ve vector
#define sz(a) (int)((a).size())
#define fi first
#define se second
#define pa pair
#define fastio  {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define ll long long int
#define fr(i, a, b); for (int i = a; i < b; i++)
#define frn(i, a, b); for (int i = a; i > b; i--)
#define mk make_pair
#define setvector(vname,value,size); for(int i=0;i<size;i++)vname[i]=value;
const ll inf = 1e18;
int main()
{
    //fastio
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ve <ll> in(n);
        inarr(i,in,n);
        ll k=1;
        fr(i,1,n)
        {
            if(in[i]!=in[i-1])
                k=2;
        }
        if(k==1)
        {
            cout<<1<<endl;
            fr(i,0,n)
            {
                cout<<"1 ";
            }
            cout<<endl;
            return 0;
        }
        if(n%2==0)
        {

            cout<<2<<endl;
            fr(i,0,n/2)
            {
                cout<<"1 2 ";
            }
            cout<<endl;
        }
        else
        {
            k=3;
            ll j=-1;
            fr(i,1,n)
            {
                if(in[i]==in[i-1])
                {
                    j=i;
                    k=2;
                }
            }
            cout<<k<<endl;
            if(k==3)
            {
                cout<<k<<endl;
                fr(i,0,n-1)
                {
                    cout<<1+i%2<<" ";
                }
                cout<<3<<endl;
            }
            else
            {
                cout<<2<<endl;
                fr(i,0,j)
                {
                    cout<<1+i%2<<" ";
                }
                fr(i,j,n)
                {
                    cout<<1+(i-1)%2<<" ";
                }
                cout<<endl;
            }

        }

    }
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define inarr(i,arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(i,arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<' ';
#define swap(a,b,t) {t=a;a=b;b=t;}
#define ve vector
#define sz(a) (int)((a).size())
#define fi first
#define se second
#define pa pair
#define fastio  {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define ll long long int
#define fr(i, a, b); for (int i = a; i < b; i++)
#define frn(i, a, b); for (int i = a; i > b; i--)
#define mk make_pair
#define setvector(vname,value,size); for(int i=0;i<size;i++)vname[i]=value;
const ll inf = 1e18;
int main()
{
    //fastio
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ve <ll> in(n);
        inarr(i,in,n);
        ll k=1;
        fr(i,1,n)
        {
            if(in[i]!=in[i-1])
                k=2;
        }
        if(k==1)
        {
            cout<<1<<endl;
            fr(i,0,n)
            {
                cout<<"1 ";
            }
            cout<<endl;
            continue;
        }
        if(n%2==0)
        {

            cout<<2<<endl;
            fr(i,0,n/2)
            {
                cout<<"1 2 ";
            }
            cout<<endl;
        }
        else
        {
            k=3;
            ll j=-1;
            fr(i,0,n)
            {
                if(in[i]==in[(i-1+n)%n])
                {
                    j=i;
                    k=2;
                }
            }
            if(k==3)
            {
                cout<<k<<endl;
                fr(i,0,n-1)
                {
                    cout<<1+i%2<<" ";
                }
                cout<<3<<endl;
            }
            else
            {
                cout<<2<<endl;
                fr(i,0,j)
                {
                    cout<<1+i%2<<" ";
                }
                fr(i,j,n)
                {
                    cout<<1+(i-1+2)%2<<" ";
                }
                cout<<endl;
            }

        }

    }
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define inarr(i,arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(i,arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<' ';
#define swap(a,b,t) {t=a;a=b;b=t;}
#define ve vector
#define sz(a) (int)((a).size())
#define fi first
#define se second
#define pa pair
#define fastio  {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define ll long long int
#define fr(i, a, b); for (int i = a; i < b; i++)
#define frn(i, a, b); for (int i = a; i > b; i--)
#define mk make_pair
#define setvector(vname,value,size); for(int i=0;i<size;i++)vname[i]=value;
const ll inf = 1e18;
int main()
{
    //fastio
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ve <ll> in(n);
        inarr(i,in,n);
        ll k=1;
        fr(i,1,n)
        {
            if(in[i]!=in[i-1])
                k=2;
        }
        if(k==1)
        {
            cout<<1<<endl;
            fr(i,0,n)
            {
                cout<<"1 ";
            }
            cout<<endl;
            return 0;
        }
        if(n%2==0)
        {

            cout<<2<<endl;
            fr(i,0,n/2)
            {
                cout<<"1 2 ";
            }
            cout<<endl;
        }
        else
        {
            k=3;
            ll j=-1;
            fr(i,1,n)
            {
                if(in[i]==in[i-1])
                {
                    j=i;
                    k=2;
                }
            }
            if(k==3)
            {
                cout<<k<<endl;
                fr(i,0,n-1)
                {
                    cout<<1+i%2<<" ";
                }
                cout<<3<<endl;
            }
            else
            {
                cout<<2<<endl;
                fr(i,0,j)
                {
                    cout<<1+i%2<<" ";
                }
                fr(i,j,n)
                {
                    cout<<1+(i-1)%2<<" ";
                }
                cout<<endl;
            }

        }

    }
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define inarr(i,arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(i,arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<' ';
#define swap(a,b,t) {t=a;a=b;b=t;}
#define ve vector
#define sz(a) (int)((a).size())
#define fi first
#define se second
#define pa pair
#define fastio  {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define ll long long int
#define fr(i, a, b); for (int i = a; i < b; i++)
#define frn(i, a, b); for (int i = a; i > b; i--)
#define mk make_pair
#define setvector(vname,value,size); for(int i=0;i<size;i++)vname[i]=value;
const ll inf = 1e18;
int main()
{
    //fastio
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ve <ll> in(n);
        inarr(i,in,n);
        ll k=1;
        fr(i,1,n)
        {
            if(in[i]!=in[i-1])
                k=2;
        }
        if(k==1)
        {
            cout<<1<<endl;
            fr(i,0,n)
            {
                cout<<"1 ";
            }
            cout<<endl;
            continue;
        }
        if(n%2==0)
        {

            cout<<2<<endl;
            fr(i,0,n/2)
            {
                cout<<"1 2 ";
            }
            cout<<endl;
        }
        else
        {
            k=3;
            ll j=-1;
            fr(i,0,n)
            {
                if(in[i]==in[(i-1+n)%n])
                {
                    j=i;
                    k=2;
                }
            }
            if(k==3)
            {
                cout<<k<<endl;
                fr(i,0,n-1)
                {
                    cout<<1+i%2<<" ";
                }
                cout<<3<<endl;
            }
            else
            {
                cout<<2<<endl;
                fr(i,0,j)
                {
                    cout<<1+i%2<<" ";
                }
                fr(i,j,n)
                {
                    cout<<1+(i-1+n)%2<<" ";
                }
                cout<<endl;
            }

        }

    }
}


#include <bits/stdc++.h>
using namespace std;
#define M (ll)(1e9+7)
#define ll long long
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        vector <ll> in(n);
        for(ll i=0;i<n;i++)
        {
            cin>>in[i];
        }
        vector <ll> color(n,-1);
        color[0]=1;
        ll k=1;
        for(ll i=1;i<n;i++)
        {
            if((in[i]==in[i-1])&&(color[(i+1)%n]==-1))
            {
                color[i]=color[i-1];
            }
            else if((in[i]!=in[i-1])&&(color[(i+1)%n]==-1))
            {
                k=2;
                color[i]=1+(color[i-1])%2;
            }
            else
            {
                if((in[i]==in[i-1])&&(in[i]==in[(i+1)%n]))
                {
                    color[i]=color[i-1];
                }
                else if((in[i]!=in[i-1])&&(in[i]!=in[(i+1)%n]))
                {
                    if(color[i-1]==color[(i+1)%n])
                    {
                        if(k==1)
                            k++;
                        color[i]=1+(color[i-1])%2;
                    }
                    else
                    {
                        if(i>=2)
                        {
                            if(in[i-1]!=in[i-2])
                            {
                                k=3;
                                color[i]=3;
                            }
                            else
                            {
                                k=2;
                                in[i-1]=1+in[i-2]%2;
                                in[i]=1+in[i-1]%2;
                            }
                        }
                    }

                }
                else
                {
                    if(color[i-1]==color[(i+1)%n])
                    {
                        k=2;
                        color[i]=1+color[i-1]%2;
                    }
                    else
                    {
                        if(in[i]==in[i-1])
                            color[i]=color[i-1];
                        else
                        {
                            color[i]=color[(i+1)%n];
                        }
                    }
                }

            }

        }
        cout<<k<<endl;
        for(ll i=0;i<n;i++)
            cout<<color[i]<<" ";
        cout<<endl;
    }
}


#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mod 1000000007
#define inarr(i,arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(i,arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<' ';
#define swap(a,b,t) {t=a;a=b;b=t;}
#define ve vector
#define sz(a) (int)((a).size())
#define fi first
#define se second
#define pa pair
#define fastio  {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define ll long long int
#define fr(i, a, b); for (int i = a; i < b; i++)
#define frn(i, a, b); for (int i = a; i > b; i--)
#define mk make_pair
#define setvector(vname,value,size); for(int i=0;i<size;i++)vname[i]=value;
const ll inf = 1e18;
int main()
{
    //fastio
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ve <ll> in(n);
        inarr(i,in,n);
        ll k=1;
        fr(i,1,n)
        {
            if(in[i]!=in[i-1])
                k=2;
        }
        if(k==1)
        {
            cout<<1<<endl;
            fr(i,0,n)
            {
                cout<<"1 ";
            }
            cout<<endl;
            continue;
        }
        if(n%2==0)
        {

            cout<<2<<endl;
            fr(i,0,n/2)
            {
                cout<<"1 2 ";
            }
            cout<<endl;
        }
        else
        {
            k=3;
            ll j=-1;
            fr(i,1,n)
            {
                if(in[i]==in[i-1])
                {
                    j=i;
                    k=2;
                }
            }
            if(k==3)
            {
                cout<<k<<endl;
                fr(i,0,n-1)
                {
                    cout<<1+i%2<<" ";
                }
                cout<<3<<endl;
            }
            else
            {
                cout<<2<<endl;
                fr(i,0,j)
                {
                    cout<<1+i%2<<" ";
                }
                fr(i,j,n)
                {
                    cout<<1+(i-1)%2<<" ";
                }
                cout<<endl;
            }

        }

    }
}


#include <bits/stdc++.h>
using namespace std;
#define M (ll)(1e9+7)
#define ll long long
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        vector <ll> in(n);
        for(ll i=0;i<n;i++)
        {
            cin>>in[i];
        }
        vector <ll> color(n,-1);
        color[0]=1;
        ll k=1;
        for(ll i=1;i<n;i++)
        {
            if((in[i]==in[i-1])&&(color[i+1]==-1))
            {
                color[i]=color[i-1];
            }
            else if((in[i]!=in[i-1])&&(color[i+1]==-1))
            {
                k=2;
                color[i]=1+(color[i-1])%2;
            }
            else
            {
                if((in[i]==in[i-1])&&(in[i]==in[i+1]))
                {
                    color[i]=color[i+1];
                }
                else if((in[i]!=in[i-1])&&(in[i]!=in[i+1]))
                {
                    if(color[i-1]==color[i+1])
                    {
                        if(k==1)
                            k++;
                        color[i]=1+(color[i-1])%2;
                    }
                    else
                    {
                        k=3;
                        color[i]=3;
                    }

                }
                else
                {
                        if(color[i-1]==color[i+1])
                        {
                            k=2;
                            color[i]=1+color[i-1]%2;
                        }
                        else
                        {
                            if(in[i]==in[i-1])
                                color[i]=color[i-1];
                            else
                            {
                                color[i]=color[i+1];
                            }
                        }
                }

            }

        }
        cout<<k<<endl;
        for(ll i=0;i<n;i++)
            cout<<color[i]<<" ";
        cout<<endl;
    }
}


#include <bits/stdc++.h>
using namespace std;
#define M (ll)(1e9+7)
#define ll long long
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll t;
    cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        vector <ll> in(n);
        for(ll i=0;i<n;i++)
        {
            cin>>in[i];
        }
        vector <ll> color(n,-1);
        color[0]=1;
        ll k=1;
        for(ll i=1;i<n;i++)
        {
            if((in[i]==in[i-1])&&(color[(i+1)%n]==-1))
            {
                color[i]=color[i-1];
            }
            else if((in[i]!=in[i-1])&&(color[(i+1)%n]==-1))
            {
                k=2;
                color[i]=1+(color[i-1])%2;
            }
            else
            {
                if((in[i]==in[i-1])&&(in[i]==in[(i+1)%n]))
                {
                    color[i]=color[i-1];
                }
                else if((in[i]!=in[i-1])&&(in[i]!=in[(i+1)%n]))
                {
                    if(color[i-1]==color[(i+1)%n])
                    {
                        if(k==1)
                            k++;
                        color[i]=1+(color[i-1])%2;
                    }
                    else
                    {
                        k=3;
                        color[i]=3;
                    }

                }
                else
                {
                        if(color[i-1]==color[(i+1)%n])
                        {
                            k=2;
                            color[i]=1+color[i-1]%2;
                        }
                        else
                        {
                            if(in[i]==in[i-1])
                                color[i]=color[i-1];
                            else
                            {
                                color[i]=color[(i+1)%n];
                            }
                        }
                }

            }

        }
        cout<<k<<endl;
        for(ll i=0;i<n;i++)
            cout<<color[i]<<" ";
        cout<<endl;
    }
}


/**
 * 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]) {
			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;
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;
    }
    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;
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;
    return ;
}
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;
}