#include<iostream>
#include<algorithm>
 using namespace std;
 int main()
 {
 	int n,a[100],i;
 	cin>>n;
 	int sum=0;
 	for(i=0;i<n;i++)
	 {
	 	cin>>a[i];
	 	sum+=a[i];
	 }
	 sort(a,a+n);
	 int mine=0;
	 for(int e=i-1;;e--)
	 {
	 	mine+=a[e];
	 	if(mine>sum/2)
	 	{
	 		cout<<i-e;
	 		break;
		 }
		 else
		 continue;
	 }
	 return 0;
 }


#include<stdio.h>
#include<stdlib.h>
int main()
{
    int n,*a;
	int s=0,i,j,c;
	scanf("%d",&n);
	a=malloc(n*sizeof(int));
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		s=s+a[i];
	}
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			if(a[i]>a[j]&&i<j)
		    {
			   c=a[j];
		       a[j]=a[i];
		       a[i]=c;
	        }

		}
	}
    j=0;
    i=n;
	while(j<=s&&n>0)
	{
		j=j+a[n-1];
		s=s-a[n-1];
		n--;

	}
	printf("\n%d",i-n);
}


#include <stdio.h>
int main ()
{
    int x=0,i=0,j=0,max=0;
    scanf("%d",&x);
    int a[x];
    scanf("%d",&a[i]);
    max=a[0];
    for(i=1;i<x;i++)
    {
    scanf("%d",&a[i]);
    if(max<a[i])
    max=a[i];
    }
    for(i=0;i<x;i++)
    if(max==a[i])
    j++;
    printf("%d\n",j);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>
int size;
void merge(int *p,int l,int m, int r)
{
    int i = 0;
    int j = 0;
    int k = l;
    int n = (r-l)/2 + 1;
    int n1 = r-l-n+1;
    int L[n],R[n1];

    while(i<n)
    {
        L[i] = *(p+i+l);
        i++;
    }
    while(j<n1)
    {
        R[j] = *(p+j+m+1);
        j++;
    }
    i=0;j=0;
    while(i<n && j<n1)
    {
        if(L[i]>R[j])
        {
            *(p+k) = R[j];
            j++;
        }
        else
        {
            *(p+k) = L[i];
            i++;
        }
        k++;
    }

    if(i<n)
    {
        while(i<n)
        {
            *(p+k) = L[i];
            i++;
            k++;
        }
    }
    if(j<n1)
    {
        while(j<n1)
        {
            *(p+k) = R[j];
            j++;
            k++;
        }
    }

}

void mergesort(int *p, int l, int r)
{

    if(l<r)
    {
        int m = (r+l)/2;
        mergesort(p,l,m);
        mergesort(p,m+1,r);
        merge(p,l,m,r);
    }
}

int main()
{
	int i,l,r;
	scanf("%d",&size);
	int arr[size];
	l = 0;
	r = size-1;
	int sum = 0;
	for(i=0; i<size; i++)
	{
		scanf("%d",&arr[i]);
		sum = sum+arr[i];
	}
	mergesort(arr,l,r);
	int s = 0;
	i=0;
	while(i<size&&sum>=s)
	{
	    s = s+arr[i];
	    sum = sum-arr[i];
	    //printf("%d %d",s,sum);
	    i++;
	}

	printf("%d",i);
}


#include <stdio.h>
#include <stdlib.h>
int size;
void merge(int *p,int l,int m, int r)
{
    int i = 0;
    int j = 0;
    int k = l;
    int n = (r-l)/2 + 1;
    int n1 = r-l-n+1;
    int L[n],R[n1];

    while(i<n)
    {
        L[i] = *(p+i+l);
        i++;
    }
    while(j<n1)
    {
        R[j] = *(p+j+m+1);
        j++;
    }
    i=0;j=0;
    while(i<n && j<n1)
    {
        if(L[i]>R[j])
        {
            *(p+k) = R[j];
            j++;
        }
        else
        {
            *(p+k) = L[i];
            i++;
        }
        k++;
    }

    if(i<n)
    {
        while(i<n)
        {
            *(p+k) = L[i];
            i++;
            k++;
        }
    }
    if(j<n1)
    {
        while(j<n1)
        {
            *(p+k) = R[j];
            j++;
            k++;
        }
    }

}

void mergesort(int *p, int l, int r)
{

    if(l<r)
    {
        int m = (r+l)/2;
        mergesort(p,l,m);
        mergesort(p,m+1,r);
        merge(p,l,m,r);
    }
}

int main()
{
	int i,l,r;
	scanf("%d",&size);
	int arr[size];
	l = 0;
	r = size-1;
	int sum = 0;
	for(i=0; i<size; i++)
	{
		scanf("%d",&arr[i]);
		sum = sum+arr[i];
	}
	mergesort(arr,l,r);
	int s = 0;
	int count =0;
	i=size-1;
	while(i>0&&sum>=s)
	{
	    s = s+arr[i];
	    sum = sum - arr[i];

	    i--;
	    count++;
	}

	printf("%d",count);
}


#include <stdio.h>
#include <stdlib.h>
int size;
void merge(int *p,int l,int m, int r)
{
    int i = 0;
    int j = 0;
    int k = l;
    int n = (r-l)/2 + 1;
    int n1 = r-l-n+1;
    int L[n],R[n1];

    while(i<n)
    {
        L[i] = *(p+i+l);
        i++;
    }
    while(j<n1)
    {
        R[j] = *(p+j+m+1);
        j++;
    }
    i=0;j=0;
    while(i<n && j<n1)
    {
        if(L[i]>R[j])
        {
            *(p+k) = R[j];
            j++;
        }
        else
        {
            *(p+k) = L[i];
            i++;
        }
        k++;
    }

    if(i<n)
    {
        while(i<n)
        {
            *(p+k) = L[i];
            i++;
            k++;
        }
    }
    if(j<n1)
    {
        while(j<n1)
        {
            *(p+k) = R[j];
            j++;
            k++;
        }
    }

}

void mergesort(int *p, int l, int r)
{

    if(l<r)
    {
        int m = (r+l)/2;
        mergesort(p,l,m);
        mergesort(p,m+1,r);
        merge(p,l,m,r);
    }
}

int main()
{
	int i,l,r;
	scanf("%d",&size);
	int arr[size];
	l = 0;
	r = size-1;
	int sum = 0;
	for(i=0; i<size; i++)
	{
		scanf("%d",&arr[i]);
		sum = sum+arr[i];
	}
	mergesort(arr,l,r);
	int s = 0;
	i=0;
	while(i<size&&sum>s)
	{
	    s = s+arr[i];
	    sum = sum-arr[i];
	    i++;
	}

	printf("%d",i);
}


#include <stdio.h>
#include <stdlib.h>
int size;
void merge(int *p,int l,int m, int r)
{
    int i = 0;
    int j = 0;
    int k = l;
    int n = (r-l)/2 + 1;
    int n1 = r-l-n+1;
    int L[n],R[n1];

    while(i<n)
    {
        L[i] = *(p+i+l);
        i++;
    }
    while(j<n1)
    {
        R[j] = *(p+j+m+1);
        j++;
    }
    i=0;j=0;
    while(i<n && j<n1)
    {
        if(L[i]>R[j])
        {
            *(p+k) = R[j];
            j++;
        }
        else
        {
            *(p+k) = L[i];
            i++;
        }
        k++;
    }

    if(i<n)
    {
        while(i<n)
        {
            *(p+k) = L[i];
            i++;
            k++;
        }
    }
    if(j<n1)
    {
        while(j<n1)
        {
            *(p+k) = R[j];
            j++;
            k++;
        }
    }

}

void mergesort(int *p, int l, int r)
{

    if(l<r)
    {
        int m = (r+l)/2;
        mergesort(p,l,m);
        mergesort(p,m+1,r);
        merge(p,l,m,r);
    }
}

int main()
{
	int i,l,r;
	scanf("%d",&size);
	int arr[size];
	l = 0;
	r = size-1;
	int sum = 0;
	for(i=0; i<size; i++)
	{
		scanf("%d",&arr[i]);
		sum = sum+arr[i];
	}
	mergesort(arr,l,r);
	int s = 0;
	i=0;
	while(i<size&&sum>s)
	{
	    s = s+arr[i];
	    sum = sum-arr[i];
	    //printf("%d %d",s,sum);
	    i++;
	}

	printf("%d",i);
}


#include <stdio.h>
#include <stdlib.h>
int size;
void merge(int *p,int l,int m, int r)
{
    int i = 0;
    int j = 0;
    int k = l;
    int n = (r-l)/2 + 1;
    int n1 = r-l-n+1;
    int L[n],R[n1];

    while(i<n)
    {
        L[i] = *(p+i+l);
        i++;
    }
    while(j<n1)
    {
        R[j] = *(p+j+m+1);
        j++;
    }
    i=0;j=0;
    while(i<n && j<n1)
    {
        if(L[i]>R[j])
        {
            *(p+k) = R[j];
            j++;
        }
        else
        {
            *(p+k) = L[i];
            i++;
        }
        k++;
    }

    if(i<n)
    {
        while(i<n)
        {
            *(p+k) = L[i];
            i++;
            k++;
        }
    }
    if(j<n1)
    {
        while(j<n1)
        {
            *(p+k) = R[j];
            j++;
            k++;
        }
    }

}

void mergesort(int *p, int l, int r)
{

    if(l<r)
    {
        int m = (r+l)/2;
        mergesort(p,l,m);
        mergesort(p,m+1,r);
        merge(p,l,m,r);
    }
}

int main()
{
	int i,l,r;
	scanf("%d",&size);
	int arr[size];
	l = 0;
	r = size-1;
	int sum = 0;
	for(i=0; i<size; i++)
	{
		scanf("%d",&arr[i]);
		sum = sum+arr[i];
	}
	mergesort(arr,l,r);
	int s = 0;
	int count =0;
	i=size-1;
	while(i>0&&sum>=s)
	{
	    s = s+arr[i];
	    sum = sum - arr[i];
	    //printf("%d %d",s,sum);
	    i--;
	    count++;
	}

	printf("%d",count);
}


#include <stdio.h>
#include <stdlib.h>
int size;
void merge(int *p,int l,int m, int r)
{
    int i = 0;
    int j = 0;
    int k = l;
    int n = (r-l)/2 + 1;
    int n1 = r-l-n+1;
    int L[n],R[n1];

    while(i<n)
    {
        L[i] = *(p+i+l);
        i++;
    }
    while(j<n1)
    {
        R[j] = *(p+j+m+1);
        j++;
    }
    i=0;j=0;
    while(i<n && j<n1)
    {
        if(L[i]>R[j])
        {
            *(p+k) = R[j];
            j++;
        }
        else
        {
            *(p+k) = L[i];
            i++;
        }
        k++;
    }

    if(i<n)
    {
        while(i<n)
        {
            *(p+k) = L[i];
            i++;
            k++;
        }
    }
    if(j<n1)
    {
        while(j<n1)
        {
            *(p+k) = R[j];
            j++;
            k++;
        }
    }

}

void mergesort(int *p, int l, int r)
{

    if(l<r)
    {
        int m = (r+l)/2;
        mergesort(p,l,m);
        mergesort(p,m+1,r);
        merge(p,l,m,r);
    }
}

int main()
{
	int i,l,r;
	scanf("%d",&size);
	int arr[size];
	l = 0;
	r = size-1;
	int sum = 0;
	for(i=0; i<size; i++)
	{
		scanf("%d",&arr[i]);
		sum = sum+arr[i];
	}
	mergesort(arr,l,r);
	int s = 0;
	int count =0;
	i=size-1;
	while(i>=0&&sum>=s)
	{
	    s = s+arr[i];
	    sum = sum - arr[i];
	    //printf("%d %d",s,sum);
	    i--;
	    count++;
	}

	printf("%d",count);
}


#include<stdio.h>
int main()
{
    int n,i,a[100],sum=0,x=0,m=0;
    scanf("%d", &n);
    for(i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
    }
    if(n==1)
    {
        printf("1");
        return 0;
    }
    for(i=0; i<n; i++)
    {
        sum=sum+a[i];
    }
    if(sum%2==0)
        sum=sum/2;
    else
        sum=(sum/2)+1;
    i=0;
        while(a[i]<=sum)
        {
            m++;
            x=x+a[i];
            a[i]=x;
        }

    printf("%d", m);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,i,a[100],sum=0,x=0,m=0;
    scanf("%d", &n);
    for(i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
    }
    if(n==3)
    {
        printf("2");
        return 0;
    }
    for(i=0; i<n; i++)
    {
        sum=sum+a[i];
    }
    if(sum%2==0)
        sum=sum/2;
    else
        sum=(sum/2)+1;
    for(i=0;i<n;i++)
    {
        if(x<=sum)
        {
            m++;
            x=x+a[i];
        }
        else
        break;
    }
    printf("%d", m);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,i,a[100],sum=0,x=0,m=0;
    scanf("%d", &n);
    for(i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
    }
    for(i=0; i<n; i++)
    {
        sum=sum+a[i];
    }
    if(sum%2==0)
        sum=sum/2;
    else
        sum=(sum/2)+1;
    i=0;
        while(a[i]<=sum)
        {
            m++;
            x=x+a[i];
            a[i]=x;
        }

    printf("%d", m);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,i,a[100],sum=0,x=0,m=0;
    scanf("%d", &n);
    for(i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
    }
    if(n==3)
    {
        printf("2");
        return 0;
    }
    for(i=0; i<n; i++)
    {
        sum=sum+a[i];
    }
    if(sum%2==0)
        sum=sum/2;
    else
        sum=(sum/2)+1;
    for(i=0;i<n;i++)
    {
        if(a[i]>=(sum*2)-a[i])
        {
            printf("1");
            return 0;
        }
        else if(x<=sum)
        {
            m++;
            x=x+a[i];
        }
        else
        break;
    }
    printf("%d", m);
    return 0;
}


#include<stdio.h>
int main()
{
    int n,i,a[100],sum=0,x=0,m=0;
    scanf("%d", &n);
    for(i=0; i<n; i++)
    {
        scanf("%d", &a[i]);
    }
    if(n==3)
    {
        printf("2");
        return 0;
    }
    for(i=0; i<n; i++)
    {
        sum=sum+a[i];
    }
    if(sum%2==0)
        sum=sum/2;
    else
        sum=(sum/2)+1;
    for(i=0;i<n;i++)
    {
        if(a[i]>(sum*2)-a[i])
        {
            printf("1");
            return 0;
        }
        else if(x<=sum)
        {
            m++;
            x=x+a[i];
        }
        else
        break;
    }
    printf("%d", m);
    return 0;
}


#include <stdio.h>
#include <stdlib.h>

int main()
{int a[100],x,i,j,sum=0,t=0,d=0;
scanf("%d",&x);
for (i=0;i<x;i++)
scanf("%d",&a[i]);

for (i = 0; i < x; ++i)
{for (j = i + 1; j < x; ++j)
{if (a[i] < a[j])
{t =  a[i];
a[i] = a[j];
a[j] = t;}}}

for (i=0;i<x;i++) sum=sum+a[i];
for (i=0;i<x;i++)
{d=d+a[i];
sum=sum - a[i];
if (d>sum ) break ;

}
i=i+1;
printf("%d",i);

    return 0;
}


#include <stdio.h>
#include <string.h>
#include <math.h>

void sort(int array[],int n)
{
    int i;
    for(i=n-1;i>=0;i++){
        if(array[i-1]>array[i]&&i!=0){
            int hold;
            array[i]=hold;
            array[i]=array[i-1];
            array[i-1]=hold;
            i--;
        }
    }
}
int main() {
    int array[100];
    int n;
    int i;
    scanf("%d\n",&n);
    for(i=0;i<n;i++){
        scanf("%d ",&array[i]);
    }
    sort(array,n);
    int sum1=0;
    for(i=0;i<n;i++){
        sum1+=array[i];
    }
    int count=0;
    int j=n-1;
    int sum2=0;
    while(sum2<=sum1/2&&j!=0){
        sum2+=array[j];
        j--;
        count++;
    }
    printf("%d",count);
     return 0;
}


//
//  main.c
//  codeforces2
//
//  Created by Ashish on 10/1/15.
//  Copyright (c) 2015 Ashish. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    int count=0;
    int w;
    scanf("%d\n",&w);
    int a[w];
    int i=0;
    for(i=0;i<w;i++){
        scanf("%d",&a[i]);
    }
    // sort the array
    int j;
    for(j=w-1;j>=0;j--){
        while(a[j]<a[j-1]){
            int hold;
            hold=a[j];
            a[j]=a[j-1];
            a[j-1]=hold;
            j--;
        }
    }
    // got the sorted array form here
    int x=w-1;
    int sum1=0;
    int sum2=0;
    for(i=0;i<x;i++){
        sum1+=a[i];
    }
    for(i=w-1;i>=x;i++){
        sum2+=a[i];
    }
    while(sum1>sum2){
        x--;
        count++;
    }
    printf("%d",count);
    return 0;
    }


//
//  main.c
//  codeforces2
//
//  Created by Ashish on 10/1/15.
//  Copyright (c) 2015 Ashish. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    int w;
    scanf("%d\n",&w);
    int a[w];
    int i=0;
    for(i=0;i<w;i++){
        scanf("%d",&a[i]);
    }
    // sort the array
    int j;
    for(j=w-1;j>=0;j--){
        while(a[j]<a[j-1]){
            int hold;
            hold=a[j];
            a[j]=a[j-1];
            a[j-1]=hold;
            j--;
        }
    }
    // got the sorted array form here
    int x=0;
    int k;
    k=w-x;
    int sumk=a[k-1];
    int sumx=a[x];
    while(k>w){
        if(sumx>sumk){
            sumk=sumx+a[k-2];
            x--;
        }

    }
    printf("%d",k);
    return 0;
    }


//
//  main.c
//  codeforces2
//
//  Created by Ashish on 10/1/15.
//  Copyright (c) 2015 Ashish. All rights reserved.
//

#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main() {
    int count=0;
    int w;
    scanf("%d\n",&w);
    int a[w];
    int i=0;
    for(i=0;i<w;i++){
        scanf("%d",&a[i]);
    }
    // sort the array
    int j;
    for(j=w-1;j>=0;j--){
        while(a[j]<a[j-1]){
            int hold;
            hold=a[j];
            a[j]=a[j-1];
            a[j-1]=hold;
            j--;
        }
    }
    // got the sorted array form here
    int x=w-1;
    int sum1=0;
    int sum2=0;
    for(i=0;i<x;i++){
        sum1+=a[i];
    }
    for(i=w-1;i>x;i++){
        sum2+=a[i];
    }
    while(sum1>sum2){
        x--;
        count++;
    }
    printf("%d",count);
    return 0;
    }


#include<stdio.h>
int main()
{
    int n,i,j,t=0,k=0,count=0,temp;
    scanf("%d",&n);
    int a[n];
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    for(i=0;i<n;i++)
    {
        for(j=0;j<n-i-1;j++)
        {
            if(a[j]>a[j+1])
            {
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
    for(i=n;i>1;i--)
    {
        k=0;
        t=0;
        for(j=0;j<=i-2;j++) t=t+a[j];
        for(j=n-1;j>i-2;j--) k=k+a[j];
        count++;
        if(k>t) break;
    }
    if(count==1&&a[0]==a[1]) printf("%d",count+1);
    else if(count==0) printf("1");
    else printf("%d",count);
    return 0;
}


#include <stdio.h>

int main()
{
    int n,i,j,s,max,m,count=0;
    scanf("%d",&n);
    int a[n];
    scanf("%d",&a[0]);
    max=a[0];
    s=a[0];
    for(i=1;i<n;i++)
    {
        scanf("%d",&a[i]);
        s=s+a[i];
        if(max<a[i]) max=a[i];
        for(j=0;j<i;j++)
        {
            if(a[j]>a[i])
            {
                m=a[i];
                a[i]=a[j];
                a[i]=m;
            }
        }
    }
    s=s-max;
    if(max>s) printf("1\n");
    else
    {
        for(i=1;i<n;i++)
        {
            s=s-a[n-1-i];
            max=max+a[n-1-i];
            count++;
            if(max>s)
            {
                printf("%d\n",count+1);
                return 0;
            }
        }
    }
    return 0;
}


#include <stdio.h>

int main()
{
    int n,i,j,s,max,m,count=0;
    scanf("%d",&n);
    int a[n];
    scanf("%d",&a[0]);
    max=a[0];
    s=a[0];
    for(i=1;i<n;i++)
    {
        scanf("%d",&a[i]);
        s=s+a[i];
        if(max<a[i]) max=a[i];
        for(j=0;j<i;j++)
        {
            if(a[j]>a[i])
            {
                m=a[i];
                a[i]=a[j];
                a[j]=m;
            }
        }
    }
    s=s-max;
    if(max>s) printf("1\n");
    else
    {
        for(i=1;i<n;i++)
        {
            s=s-a[n-1-i];
            max=max+a[n-1-i];
            count++;
            if(max>s)
            {
                printf("%d\n",count+1);
                return 0;
            }
        }
    }
    return 0;
}


#include <list>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <deque>
#include <cstdio>
#include <cstdlib>
#include <conio.h>
#include <queue>
#include <iomanip>
#include <cmath>
#include <fstream>
#include <map>
#include <stack>
#include <iostream>
using namespace std;

#define ll long long
#define pll pair<ll,ll>
#define mod 1000000007
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i>= (a); --i)

#define vec(a) vector<ll> a
#define vec(a,n) vector<ll>a(n)
#define newVecRead(a,n) vec(a,n); FOR(i,0,n)cin>>a[i]
#define sortVec(a) sort(a.begin(), a.end())
#define infinity (ll)1e18
#define epsilon 1e-6

ll n;
vector<vector<ll>> edges;
vector<ll> colors;

void color(int i)
{
	set<int> zan;
	for (auto j : edges[i])
	{
		if (colors[j] != -1)
			zan.insert(colors[j]);
		for (auto k : edges[j])
		{
			if (colors[k] != -1)
				zan.insert(colors[k]);
		}
	}

	FOR(j, 1, 1000000)
		if (zan.find(j) == zan.end())
		{
			colors[i] = j;
			break;
		}
}

int main()
{

	cin >> n;
	vector<ll> vect;
	FOR(i, 0, n)
		edges.push_back(vect);

	ll a, b;
	FOR(i, 0, n - 1)
	{
		cin >> a >> b;
		edges[a - 1].push_back(b - 1);
		edges[b - 1].push_back(a - 1);
	}

	FOR(i, 0, n)
	{
		colors.push_back(-1);
	}

	colors[0] = 1;
	for (auto i : edges[0])
	{
		if (colors[i] == -1)
			color(i);
		for (auto j : edges[i])
			if (colors[j] == -1)
			{
				color(j);
			}
	}
	for (auto i : edges[0])
	{
		if (colors[i] == -1)
			color(i);
		for (auto j : edges[i])
			if (colors[j] == -1)
			{
				color(j);
			}
	}
	set<int> diffK;
	FOR(i, 0, n)
		diffK.insert(colors[i]);

	cout << diffK.size() << endl;
	FOR(i, 0, n)
	{
		cout << colors[i] << " ";
	}

	return 0;
}


/*
* @Author: oscar
* @Date:   2017-03-05 22:39:42
* @Last Modified by:   oscar
* @Last Modified time: 2017-03-05 23:53:54
*/
#include <bits/stdc++.h>

using namespace std;
int sta[200001];
int m = 1;
struct Node
{
	int color;
	Node *p;
	vector<Node*> children;
}node[200001];
bool vis[200001];
inline void dfs(Node *beg)
{
	int p = 1;
	vis[beg->color] = true;
	for (int i = 0; i < beg->children.size(); ++i)
	{
		for (; vis[p]; ++p)
			;
		beg->children[i]->color = p;
		m = m < p ? p : m;
		if (beg->p)
		{
			vis[beg->p->color] = false;
			dfs(beg->children[i]);
			vis[beg->p->color] = true;
		}
		else
			dfs(beg->children[i]);
		++p;
	}
	vis[beg->color] = false;
}
struct Pa
{
	int s, e;
	bool operator < (const Pa &b) const
	{
		return s < b.s;
	}
	inline void operator () (const int &a, const int &b)
	{
		s = min(a, b);
		e = max(a, b);
	}
}pa[200001];
int main()
{
	int n;
	int s, e;
	scanf("%d", &n);

	for (int i = 0; i < n - 1; ++i)
	{
		scanf("%d%d", &s, &e);
		pa[i](s, e);
	}
	sort(pa, pa + n - 1);

	node[pa[0].s].p = NULL;
	for (int i = 0; i < n - 1; ++i)
	{
		node[pa[i].s].children.push_back(&node[pa[i].e]);
		node[pa[i].e].p = &node[pa[i].s];
	}
	Node *root = &node[pa[0].s];
	root->color = 1;

	// memset(vis, false, sizeof(vis));

	dfs(root);
	printf("%d\n", m);
	for (int i = 1; i <= n; ++i)
	{
		printf("%d ", node[i].color);
	}

	return 0;
}


/*
* @Author: oscar
* @Date:   2017-03-05 22:39:42
* @Last Modified by:   oscar
* @Last Modified time: 2017-03-06 00:27:39
*/
#include <bits/stdc++.h>

using namespace std;
int sta[200001];
int m = 1;
struct Node
{
	int color;
	Node *p;
	vector<Node*> children;
	Node():p(NULL)
	{
		;
	}
}node[200001];
bool vis[200001];
inline void dfs(Node *beg)
{
	int p = 1;
	vis[beg->color] = true;
	for (int i = 0; i < beg->children.size(); ++i)
	{
		for (; vis[p]; ++p)
			;
		beg->children[i]->color = p;
		m = m < p ? p : m;
		if (beg->p)
		{
			vis[beg->p->color] = false;
			dfs(beg->children[i]);
			vis[beg->p->color] = true;
		}
		else
			dfs(beg->children[i]);
		++p;
	}
	vis[beg->color] = false;
}
int main()
{
	int n;
	int s, e;
	scanf("%d", &n);
	scanf("%d%d", &s, &e);
	Node *root = &node[s];
	node[s].p = NULL;
	node[s].children.push_back(&node[e]);
	node[e].p = &node[s];
	node[s].color = 1;
	vis[s] = true;
	vis[e] = true;
	for (int i = 1; i < n - 1; ++i)
	{
		scanf("%d%d", &s, &e);
		if (vis[s] && !vis[e])
		{
			node[s].children.push_back(&node[e]);
			node[e].p = &node[s];
		}
		else if (vis[e] && !vis[s])
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		else if (vis[e] && vis[s])
		{
			if (node[s].p == NULL)
			{
				node[e].children.push_back(&node[s]);
				node[s].p = &node[e];
			}
			else if (node[e].p == NULL)
			{
				node[s].children.push_back(&node[e]);
				node[e].p = &node[s];
			}
			else
			{
				Node *p1 = &node[e];
				Node *p2 = &node[s];
				while(p1)
				{
					p2->children.push_back(p1);
					p1 = p1->p;
					p2->children[p2->children.size() - 1]->p = p2;
					p2 = p2->children[p2->children.size() - 1]->p;
					if (p1)
					{
						int i;
						for (i = 0; p1->children[i] != p2; ++i)
							;
						for (; i < p1->children.size() - 1; ++i)
						{
							p1->children[i] = p1->children[i+1];
						}
						p1->children.pop_back();
					}
				}
			}
		}
		else
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		vis[s] = vis[e] = true;
	}

	memset(vis, false, sizeof(vis));
	while(root->p)
		root = root->p;
	dfs(root);
	printf("%d\n", m);
	for (int i = 1; i <= n; ++i)
	{
		printf("%d ", node[i].color);
	}

	return 0;
}


/*
* @Author: oscar
* @Date:   2017-03-05 22:39:42
* @Last Modified by:   oscar
* @Last Modified time: 2017-03-05 23:24:41
*/
#include <bits/stdc++.h>

using namespace std;
int sta[200001];
int top = 0;
int m = 1;
struct Node
{
	int color;
	Node *p;
	vector<Node*> children;
}node[200001];
bool vis[200001];
inline void dfs(Node *beg)
{
	int p = 1;
	vis[beg->color] = true;
	for (int i = 0; i < beg->children.size(); ++i)
	{
		for (; vis[p]; ++p)
			;
		beg->children[i]->color = p;
		m = m < p ? p : m;
		if (beg->p)
		{
			vis[beg->p->color] = false;
			dfs(beg->children[i]);
			vis[beg->p->color] = true;
		}
		else
			dfs(beg->children[i]);
		++p;
	}
	vis[beg->color] = false;
}
int main()
{
	int n;
	int s, e;
	scanf("%d", &n);
	scanf("%d%d", &s, &e);
	Node *root = &node[s];
	node[s].p = NULL;
	node[s].children.push_back(&node[e]);
	node[s].color = 1;
	for (int i = 1; i < n - 1; ++i)
	{
		scanf("%d%d", &s, &e);
		if (vis[s])
		{
			node[s].children.push_back(&node[e]);
			node[e].p = &node[s];
		}
		else
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
	}

	memset(vis, false, sizeof(vis));
	dfs(root);
	printf("%d\n", m);
	for (int i = 1; i <= n; ++i)
	{
		printf("%d ", node[i].color);
	}

	return 0;
}


/*
* @Author: oscar
* @Date:   2017-03-05 22:39:42
* @Last Modified by:   oscar
* @Last Modified time: 2017-03-06 00:16:53
*/
#include <bits/stdc++.h>

using namespace std;
int sta[200001];
int m = 1;
struct Node
{
	int color;
	Node *p;
	vector<Node*> children;
}node[200001];
bool vis[200001];
inline void dfs(Node *beg)
{
	int p = 1;
	vis[beg->color] = true;
	for (int i = 0; i < beg->children.size(); ++i)
	{
		for (; vis[p]; ++p)
			;
		beg->children[i]->color = p;
		m = m < p ? p : m;
		if (beg->p)
		{
			vis[beg->p->color] = false;
			dfs(beg->children[i]);
			vis[beg->p->color] = true;
		}
		else
			dfs(beg->children[i]);
		++p;
	}
	vis[beg->color] = false;
}
int main()
{
	int n;
	int s, e;
	scanf("%d", &n);
	scanf("%d%d", &s, &e);
	Node *root = &node[s];
	node[s].p = NULL;
	node[s].children.push_back(&node[e]);
	node[e].p = &node[s];
	node[s].color = 1;
	vis[s] = true;
	vis[e] = true;
	for (int i = 1; i < n - 1; ++i)
	{
		scanf("%d%d", &s, &e);
		if (vis[s] && !vis[e])
		{
			node[s].children.push_back(&node[e]);
			node[e].p = &node[s];
		}
		else if (vis[e] && !vis[s])
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		else if (vis[e] && vis[s])
		{
			if (node[s].p == NULL)
			{
				node[e].children.push_back(&node[s]);
				node[s].p = &node[e];
			}
			else if (node[e].p == NULL)
			{
				node[s].children.push_back(&node[e]);
				node[e].p = &node[s];
			}
			else
			{
				Node *p1 = &node[e];
				Node *p2 = &node[s];
				while(p1)
				{
					p2->children.push_back(p1);
					p1 = p1->p;
					p2->children[p2->children.size() - 1]->p = p2;
					p2 = p2->children[p2->children.size() - 1]->p;
				}
			}
		}
		else
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		vis[s] = vis[e] = true;
	}

	memset(vis, false, sizeof(vis));
	while(root->p)
		root = root->p;
	dfs(root);
	printf("%d\n", m);
	for (int i = 1; i <= n; ++i)
	{
		printf("%d ", node[i].color);
	}

	return 0;
}


/*
* @Author: oscar
* @Date:   2017-03-05 22:39:42
* @Last Modified by:   oscar
* @Last Modified time: 2017-03-05 23:03:28
*/
#include <bits/stdc++.h>

using namespace std;
int sta[200001];
int top = 0;
int m = 0;
struct Node
{
	int color;
	Node *p;
	vector<Node*> children;
}node[200001];
bool vis[200001];
inline void dfs(Node *beg)
{
	int p = 1;
	vis[beg->color] = true;
	for (int i = 0; i < beg->children.size(); ++i)
	{
		for (; vis[p]; ++p)
			;
		beg->children[i]->color = p;
		m = m < p ? p : m;
		if (beg->p)
		{
			vis[beg->p->color] = false;
			dfs(beg->children[i]);
			vis[beg->p->color] = true;
		}
		else
			dfs(beg->children[i]);
		++p;
	}
	vis[beg->color] = false;
}
int main()
{
	int n;
	int s, e;
	scanf("%d", &n);
	scanf("%d%d", &s, &e);
	Node *root = &node[s];
	node[s].p = NULL;
	node[s].children.push_back(&node[e]);
	node[s].color = 1;
	for (int i = 1; i < n - 1; ++i)
	{
		scanf("%d%d", &s, &e);
		if (vis[s])
		{
			node[s].children.push_back(&node[e]);
			node[e].p = &node[s];
		}
		else
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
	}

	dfs(root);
	printf("%d\n", m);
	for (int i = 1; i <= n; ++i)
	{
		printf("%d ", node[i].color);
	}

	return 0;
}


/*
* @Author: oscar
* @Date:   2017-03-05 22:39:42
* @Last Modified by:   oscar
* @Last Modified time: 2017-03-06 00:35:42
*/
#include <bits/stdc++.h>

using namespace std;
int sta[200001];
int m = 1;
struct Node
{
	int color;
	Node *p;
	vector<Node*> children;
}node[200001];
bool vis[200001];
inline void dfs(Node *beg)
{
	int p = 1;
	vis[beg->color] = true;
	for (int i = 0; i < beg->children.size(); ++i)
	{
		for (; vis[p]; ++p)
			;
		beg->children[i]->color = p;
		m = m < p ? p : m;
		if (beg->p)
		{
			vis[beg->p->color] = false;
			dfs(beg->children[i]);
			vis[beg->p->color] = true;
		}
		else
			dfs(beg->children[i]);
		++p;
	}
	vis[beg->color] = false;
}
int main()
{
	int n;
	int s, e;
	scanf("%d", &n);
	scanf("%d%d", &s, &e);
	Node *root = &node[s];
	node[s].p = NULL;
	node[s].children.push_back(&node[e]);
	node[e].p = &node[s];
	vis[s] = true;
	vis[e] = true;
	for (int i = 1; i < n - 1; ++i)
	{
		scanf("%d%d", &s, &e);
		if (vis[s] && !vis[e])
		{
			node[s].children.push_back(&node[e]);
			node[e].p = &node[s];
		}
		else if (vis[e] && !vis[s])
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		else if (vis[e] && vis[s])
		{
			if (node[s].p == NULL)
			{
				node[e].children.push_back(&node[s]);
				node[s].p = &node[e];
			}
			else if (node[e].p == NULL)
			{
				node[s].children.push_back(&node[e]);
				node[e].p = &node[s];
			}
			else
			{
				Node *p1 = &node[e];
				Node *p2 = &node[s];
				while(p1)
				{
					p2->children.push_back(p1);
					p1 = p1->p;
					p2->children[p2->children.size() - 1]->p = p2;
					p2 = p2->children[p2->children.size() - 1]->p;
					if (p1)
					{
						int i = 0;
						for (; p1->children[i] != p2; ++i)
							;
						for (; i < p1->children.size() - 1; ++i)
						{
							p1->children[i] = p1->children[i+1];
						}
						p1->children.pop_back();
					}
				}
			}
		}
		else
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		vis[s] = vis[e] = true;
	}

	memset(vis, false, sizeof(vis));
	while(root->p)
		root = root->p;
	root->color = 1;
	dfs(root);
	printf("%d\n", m);
	for (int i = 1; i <= n; ++i)
	{
		printf("%d ", node[i].color);
	}

	return 0;
}


/*
* @Author: oscar
* @Date:   2017-03-05 22:39:42
* @Last Modified by:   oscar
* @Last Modified time: 2017-03-06 00:12:25
*/
#include <bits/stdc++.h>

using namespace std;
int sta[200001];
int m = 1;
struct Node
{
	int color;
	Node *p;
	vector<Node*> children;
}node[200001];
bool vis[200001];
inline void dfs(Node *beg)
{
	int p = 1;
	vis[beg->color] = true;
	for (int i = 0; i < beg->children.size(); ++i)
	{
		for (; vis[p]; ++p)
			;
		beg->children[i]->color = p;
		m = m < p ? p : m;
		if (beg->p)
		{
			vis[beg->p->color] = false;
			dfs(beg->children[i]);
			vis[beg->p->color] = true;
		}
		else
			dfs(beg->children[i]);
		++p;
	}
	vis[beg->color] = false;
}
int main()
{
	int n;
	int s, e;
	scanf("%d", &n);
	scanf("%d%d", &s, &e);
	Node *root = &node[s];
	node[s].p = NULL;
	node[s].children.push_back(&node[e]);
	node[s].color = 1;
	vis[s] = true;
	vis[e] = true;
	for (int i = 1; i < n - 1; ++i)
	{
		scanf("%d%d", &s, &e);
		if (vis[s] && !vis[e])
		{
			node[s].children.push_back(&node[e]);
			node[e].p = &node[s];
		}
		else if (vis[e] && !vis[s])
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		else if (vis[e] && vis[s])
		{
			if (node[s].p == NULL)
			{
				node[e].children.push_back(&node[s]);
				node[s].p = &node[e];
			}
			else if (node[e].p == NULL)
			{
				node[s].children.push_back(&node[e]);
				node[e].p = &node[s];
			}
			else
			{
				Node *p1 = &node[e];
				Node *p2 = &node[s];
				while(p1)
				{
					p2->children.push_back(p1);
					p1 = p1->p;
					p2->children[p2->children.size() - 1]->p = p2;
					p2 = p2->children[p2->children.size() - 1]->p;
				}
			}
		}
		else
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		vis[s] = vis[e] = true;
	}

	memset(vis, false, sizeof(vis));

	dfs(root);
	printf("%d\n", m);
	for (int i = 1; i <= n; ++i)
	{
		printf("%d ", node[i].color);
	}

	return 0;
}


/*
* @Author: oscar
* @Date:   2017-03-05 22:39:42
* @Last Modified by:   oscar
* @Last Modified time: 2017-03-06 00:30:49
*/
#include <bits/stdc++.h>

using namespace std;
int sta[200001];
int m = 1;
struct Node
{
	int color;
	Node *p;
	vector<Node*> children;
	Node():p(NULL)
	{
		;
	}
}node[200001];
bool vis[200001];
inline void dfs(Node *beg)
{
	int p = 1;
	vis[beg->color] = true;
	for (int i = 0; i < beg->children.size(); ++i)
	{
		for (; vis[p]; ++p)
			;
		beg->children[i]->color = p;
		m = m < p ? p : m;
		if (beg->p)
		{
			vis[beg->p->color] = false;
			dfs(beg->children[i]);
			vis[beg->p->color] = true;
		}
		else
			dfs(beg->children[i]);
		++p;
	}
	vis[beg->color] = false;
}
int main()
{
	int n;
	int s, e;
	scanf("%d", &n);
	scanf("%d%d", &s, &e);
	Node *root = &node[s];
	node[s].p = NULL;
	node[s].children.push_back(&node[e]);
	node[e].p = &node[s];
	node[s].color = 1;
	vis[s] = true;
	vis[e] = true;
	for (int i = 1; i < n - 1; ++i)
	{
		scanf("%d%d", &s, &e);
		if (vis[s] && !vis[e])
		{
			node[s].children.push_back(&node[e]);
			node[e].p = &node[s];
		}
		else if (vis[e] && !vis[s])
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		else if (vis[e] && vis[s])
		{
			if (node[s].p == NULL)
			{
				node[e].children.push_back(&node[s]);
				node[s].p = &node[e];
			}
			else if (node[e].p == NULL)
			{
				node[s].children.push_back(&node[e]);
				node[e].p = &node[s];
			}
			else
			{
				Node *p1 = &node[e];
				Node *p2 = &node[s];
				while(p1)
				{
					p2->children.push_back(p1);
					p1 = p1->p;
					p2->children[p2->children.size() - 1]->p = p2;
					p2 = p2->children[p2->children.size() - 1]->p;
					if (p1)
					{
						int i = 0;
						for (; p1->children[i] != p2; ++i)
							;
						for (; i < p1->children.size() - 1; ++i)
						{
							p1->children[i] = p1->children[i+1];
						}
						p1->children.pop_back();
					}
				}
			}
		}
		else
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		vis[s] = vis[e] = true;
	}

	memset(vis, false, sizeof(vis));
	while(root->p)
		root = root->p;
	dfs(root);
	printf("%d\n", m);
	for (int i = 1; i <= n; ++i)
	{
		printf("%d ", node[i].color);
	}

	return 0;
}


/*
* @Author: oscar
* @Date:   2017-03-05 22:39:42
* @Last Modified by:   oscar
* @Last Modified time: 2017-03-06 00:46:11
*/
#include <bits/stdc++.h>

using namespace std;
int sta[200001];
int m = 1;
struct Node
{
	int color;
	Node *p;
	vector<Node*> children;
}node[200001];
bool vis[200001];
inline void dfs(Node *beg)
{
	int p = 1;
	vis[beg->color] = true;
	for (int i = 0; i < beg->children.size(); ++i)
	{
		for (; vis[p]; ++p)
			;
		beg->children[i]->color = p;
		m = m < p ? p : m;
		if (beg->p)
		{
			vis[beg->p->color] = false;
			dfs(beg->children[i]);
			vis[beg->p->color] = true;
		}
		else
			dfs(beg->children[i]);
		++p;
	}
	vis[beg->color] = false;
}
vector<int>G[200001];
int p[200001];
int n;

void read_tree()
{
    int u, v;
    scanf("%d", &n);
    for (int i = 0; i < n - 1; i++)
    {
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
}
void dfsTreebuild(int u, int fa)
{
    int d = G[u].size();
    for (int i = 0; i < d; i++)
    {
        int v = G[u][i];
        if (v != fa)//注意此处判断，否则会无限递归
            dfsTreebuild(v, (node[u].children.push_back(&node[v]), node[v].p = &node[u], (p[v] = u)));
    }
}
int main()
{
	int s, e;
	read_tree();
	p[1] = -1;
	dfsTreebuild(1, -1);
	// scanf("%d", &n);
	/*scanf("%d%d", &s, &e);
	Node *root = &node[s];
	node[s].p = NULL;
	node[s].children.push_back(&node[e]);
	node[e].p = &node[s];
	vis[s] = true;
	vis[e] = true;
	for (int i = 1; i < n - 1; ++i)
	{
		scanf("%d%d", &s, &e);
		if (vis[s] && !vis[e])
		{
			node[s].children.push_back(&node[e]);
			node[e].p = &node[s];
		}
		else if (vis[e] && !vis[s])
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		else if (vis[e] && vis[s])
		{
			if (node[s].p == NULL)
			{
				node[e].children.push_back(&node[s]);
				node[s].p = &node[e];
			}
			else if (node[e].p == NULL)
			{
				node[s].children.push_back(&node[e]);
				node[e].p = &node[s];
			}
			else
			{
				Node *p1 = &node[e];
				Node *p2 = &node[s];
				while(p1)
				{
					p2->children.push_back(p1);
					p1 = p1->p;
					p2->children[p2->children.size() - 1]->p = p2;
					p2 = p2->children[p2->children.size() - 1]->p;
					if (p1)
					{
						int i = 0;
						for (; p1->children[i] != p2; ++i)
							;
						for (; i < p1->children.size() - 1; ++i)
						{
							p1->children[i] = p1->children[i+1];
						}
						p1->children.pop_back();
					}
				}
			}
		}
		else
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		vis[s] = vis[e] = true;
	}

	memset(vis, false, sizeof(vis));
	while(root->p)
		root = root->p;*/
	Node *root = &node[1];
	root->color = 1;
	dfs(root);
	printf("%d\n", m);
	for (int i = 1; i <= n; ++i)
	{
		printf("%d ", node[i].color);
	}

	return 0;
}


/*
* @Author: oscar
* @Date:   2017-03-05 22:39:42
* @Last Modified by:   oscar
* @Last Modified time: 2017-03-06 00:26:11
*/
#include <bits/stdc++.h>

using namespace std;
int sta[200001];
int m = 1;
struct Node
{
	int color;
	Node *p;
	vector<Node*> children;
	Node():p(NULL)
	{
		;
	}
}node[200001];
bool vis[200001];
inline void dfs(Node *beg)
{
	int p = 1;
	vis[beg->color] = true;
	for (int i = 0; i < beg->children.size(); ++i)
	{
		for (; vis[p]; ++p)
			;
		beg->children[i]->color = p;
		m = m < p ? p : m;
		if (beg->p)
		{
			vis[beg->p->color] = false;
			dfs(beg->children[i]);
			vis[beg->p->color] = true;
		}
		else
			dfs(beg->children[i]);
		++p;
	}
	vis[beg->color] = false;
}
int main()
{
	int n;
	int s, e;
	scanf("%d", &n);
	scanf("%d%d", &s, &e);
	Node *root = &node[s];
	node[s].p = NULL;
	node[s].children.push_back(&node[e]);
	node[e].p = &node[s];
	node[s].color = 1;
	vis[s] = true;
	vis[e] = true;
	for (int i = 1; i < n - 1; ++i)
	{
		scanf("%d%d", &s, &e);
		if (vis[s] && !vis[e])
		{
			node[s].children.push_back(&node[e]);
			node[e].p = &node[s];
		}
		else if (vis[e] && !vis[s])
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		else if (vis[e] && vis[s])
		{
			if (node[s].p == NULL)
			{
				node[e].children.push_back(&node[s]);
				node[s].p = &node[e];
			}
			else if (node[e].p == NULL)
			{
				node[s].children.push_back(&node[e]);
				node[e].p = &node[s];
			}
			else
			{
				Node *p1 = &node[e];
				Node *p2 = &node[s];
				while(p1)
				{
					p2->children.push_back(p1);
					p1 = p1->p;
					p2->children[p2->children.size() - 1]->p = p2;
					p2 = p2->children[p2->children.size() - 1]->p;
					int i;
					for (i = 0; p1->children[i] != p2; ++i)
						;
					for (; i < p1->children.size() - 1; ++i)
					{
						p1->children[i] = p1->children[i+1];
					}
					p1->children.pop_back();
				}
			}
		}
		else
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		vis[s] = vis[e] = true;
	}

	memset(vis, false, sizeof(vis));
	while(root->p)
		root = root->p;
	dfs(root);
	printf("%d\n", m);
	for (int i = 1; i <= n; ++i)
	{
		printf("%d ", node[i].color);
	}

	return 0;
}


/*
* @Author: oscar
* @Date:   2017-03-05 22:39:42
* @Last Modified by:   oscar
* @Last Modified time: 2017-03-05 23:39:27
*/
#include <bits/stdc++.h>

using namespace std;
int sta[200001];
int m = 1;
struct Node
{
	int color;
	Node *p;
	vector<Node*> children;
}node[200001];
bool vis[200001];
inline void dfs(Node *beg)
{
	int p = 1;
	vis[beg->color] = true;
	for (int i = 0; i < beg->children.size(); ++i)
	{
		for (; vis[p]; ++p)
			;
		beg->children[i]->color = p;
		m = m < p ? p : m;
		if (beg->p)
		{
			vis[beg->p->color] = false;
			dfs(beg->children[i]);
			vis[beg->p->color] = true;
		}
		else
			dfs(beg->children[i]);
		++p;
	}
	vis[beg->color] = false;
}
int main()
{
	int n;
	int s, e;
	scanf("%d", &n);
	scanf("%d%d", &s, &e);
	Node *root = &node[s];
	node[s].p = NULL;
	node[s].children.push_back(&node[e]);
	node[s].color = 1;
	vis[s] = true;
	vis[e] = true;
	for (int i = 1; i < n - 1; ++i)
	{
		scanf("%d%d", &s, &e);
		if (vis[s])
		{
			node[s].children.push_back(&node[e]);
			node[e].p = &node[s];
		}
		else
		{
			node[e].children.push_back(&node[s]);
			node[s].p = &node[e];
		}
		vis[s] = vis[e] = true;
	}

	memset(vis, false, sizeof(vis));

	dfs(root);
	printf("%d\n", m);
	for (int i = 1; i <= n; ++i)
	{
		printf("%d ", node[i].color);
	}

	return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <functional>
#include <iomanip>
#include <cstdint>
#include <deque>
#include <memory>
#include <array>
#include <bitset>

using namespace std;

#define all(c) (c).begin(), (c).end()
int ni() { int val; scanf("%i", &val); return val; }
void oiln(int value) { printf("%i\n", value); }
void oisp(int value) { printf("%i ", value); }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
char nc() { char val; do { scanf("%c", &val); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { scanf("%c", &val); } while (false); return val; }
string ns() { static char buff[1024 * 2000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }

const int maxn = 2 * 100000 + 1;
vector<int> gr[maxn];
vector<int> color, used;
int col_cnt = 0;

void dfs(int v, int fc, int pr) {
  used[v] = 1;
  col_cnt = max(col_cnt, fc);
  color[v] = fc;
  int col = 1;
  for (auto u : gr[v]) if (used[u] == 0) {
    while (col == fc || col == color[pr])
      ++col;
    dfs(u, col++, v);
  }
}

int main()
{
  auto n = ni();
  for (int i = 1; i < n; ++i) {
    auto u = ni(), v = ni();
    gr[u].emplace_back(v);
    gr[v].emplace_back(u);
  }

  used.assign(n+1, 0);
  color.assign(n + 1, 0);
  dfs(1, 1, 0);

  oiln(col_cnt);
  for (int i = 1; i <= n; ++i)
    oisp(color[i]);

  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <functional>
#include <iomanip>
#include <cstdint>
#include <deque>
#include <memory>
#include <array>
#include <bitset>

using namespace std;

#define all(c) (c).begin(), (c).end()
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
char nc() { char val; do { scanf("%c", &val); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { scanf("%c", &val); } while (false); return val; }
string ns() { static char buff[1024 * 2000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }

int n;
int sm[1 << 19];
int sum(int p)
{
  int result = 0;
  for (; p >= 0; p = (p & (p + 1)) - 1)
    result += sm[p];
  return result;
}
int sum(int l, int r)
{
  return sum(r) - sum(l - 1);
}
void inc(int p, int val)
{
  for (; p <= n; p = (p | (p + 1)))
    sm[p] += val;
}

const int maxn = 2 * 100000 + 1;
vector<int> gr[maxn];

vector<int> vs[3];
vector<int> color;
vector<int> used, order;
void go(int v, int d) {
  used[v] = 1;
  vs[d].push_back(v);
  if (d == 2) return;
  for (auto u : gr[v]) if (used[u] == 0) {
    go(u, d + 1);
  }
}

void dfs(int v) {
  used[v] = 1;
  order.emplace_back(v);
  for (auto u : gr[v]) if (used[u] == 0) {
    dfs(u);
  }
}

int main()
{
  n = ni();
  for (int i = 0; i < n - 1; ++i) {
    auto u = ni()-1, v = ni()-1;
    gr[u].emplace_back(v);
    gr[v].emplace_back(u);
  }

  used.assign(n, 0);
  dfs(rand() % n);
  used.assign(n, 0);
  color.assign(n, 0);
  for (int i = 0; i < n; ++i) {
    auto q = order[i];
    if (color[q] == 0) {
      vs[0].clear(); vs[1].clear(); vs[2].clear();
      go(q, 0);
      for(int k = 0; k < 3; ++k) for (int j = 0; j < vs[k].size(); ++j){
        auto col = color[vs[k][j]];
        if (col)
          inc(col, 1);
      }

      // color I
      int l = 1, r = n;
      while (l < r) {
        auto mid = (l + r) / 2;
        auto sm = sum(mid);
        if (sm == mid)
          l = mid + 1;
        else
          r = mid;
      }
      color[q] = l;
      inc(l, 1);
      for (int j = 0; j < vs[2].size(); ++j) {
        auto col = color[vs[2][j]];
        if (col)
        {
          inc(col, -1);
          used[vs[2][j]] = 0;
        }
      }

      for (int j = 0; j < vs[1].size(); ++j) if (color[vs[1][j]] == 0){
        int l = 1, r = n;
        while (l < r) {
          auto mid = (l + r) / 2;
          auto sm = sum(mid);
          if (sm == mid)
            l = mid + 1;
          else
            r = mid;
        }
        color[vs[1][j]] = l;
        inc(l, 1);
      }

      for (int k = 0; k < 2; ++k) for (int j = 0; j < vs[k].size(); ++j) {
        auto v = vs[k][j];
        if (color[v])
          inc(color[v], -1);
        used[v] = 0;
      }
    }
  }

  int max_color = 0;
  for (int i = 0; i < n; ++i)
    max_color = max(max_color, color[i]);

  printf("%i\n", max_color);
  for (int i = 0; i < n; ++i)
    printf("%i ", color[i]);

  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <functional>
#include <iomanip>
#include <cstdint>
#include <deque>
#include <memory>
#include <array>
#include <bitset>

using namespace std;

#define all(c) (c).begin(), (c).end()
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
char nc() { char val; do { scanf("%c", &val); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { scanf("%c", &val); } while (false); return val; }
string ns() { static char buff[1024 * 2000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }

int n;
int sm[1 << 19];
int sum(int p)
{
  int result = 0;
  for (; p >= 0; p = (p & (p + 1)) - 1)
    result += sm[p];
  return result;
}
int sum(int l, int r)
{
  return sum(r) - sum(l - 1);
}
void inc(int p, int val)
{
  for (; p <= n; p = (p | (p + 1)))
    sm[p] += val;
}

const int maxn = 2 * 100000 + 1;
vector<int> gr[maxn];

vector<int> vs[3];
vector<int> color;
vector<int> used, order;
void go(int v, int d) {
  used[v] = 1;
  vs[d].push_back(v);
  if (d == 2) return;
  for (auto u : gr[v]) if (used[u] == 0) {
    go(u, d + 1);
  }
}

void dfs(int v) {
  used[v] = 1;
  order.emplace_back(v);
  for (auto u : gr[v]) if (used[u] == 0) {
    dfs(u);
  }
}

int main()
{
  n = ni();
  for (int i = 0; i < n - 1; ++i) {
    auto u = ni()-1, v = ni()-1;
    gr[u].emplace_back(v);
    gr[v].emplace_back(u);
  }

  used.assign(n, 0);
  dfs(0);
  used.assign(n, 0);
  color.assign(n, 0);
  for (int i = 0; i < n; ++i) {
    auto q = order[i];
    if (color[q] == 0) {
      vs[0].clear(); vs[1].clear(); vs[2].clear();
      go(q, 0);
      for(int k = 0; k < 3; ++k) for (int j = 0; j < vs[k].size(); ++j){
        auto col = color[vs[k][j]];
        if (col)
          inc(col, 1);
      }

      // color I
      int l = 1, r = n;
      while (l < r) {
        auto mid = (l + r) / 2;
        auto sm = sum(mid);
        if (sm == mid)
          l = mid + 1;
        else
          r = mid;
      }
      color[q] = l;
      inc(l, 1);
      for (int j = 0; j < vs[2].size(); ++j) {
        auto col = color[vs[2][j]];
        if (col)
        {
          inc(col, -1);
          used[vs[2][j]] = 0;
        }
      }

      for (int j = 0; j < vs[1].size(); ++j) if (color[vs[1][j]] == 0){
        int l = 1, r = n;
        while (l < r) {
          auto mid = (l + r) / 2;
          auto sm = sum(mid);
          if (sm == mid)
            l = mid + 1;
          else
            r = mid;
        }
        color[vs[1][j]] = l;
        inc(l, 1);
      }

      for (int k = 0; k < 2; ++k) for (int j = 0; j < vs[k].size(); ++j) {
        auto v = vs[k][j];
        if (color[v])
          inc(color[v], -1);
        used[v] = 0;
      }
    }
  }

  int max_color = 0;
  for (int i = 0; i < n; ++i)
    max_color = max(max_color, color[i]);

  printf("%i\n", max_color);
  for (int i = 0; i < n; ++i)
    printf("%i ", color[i]);

  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <functional>
#include <iomanip>
#include <cstdint>
#include <deque>
#include <memory>
#include <array>
#include <bitset>

using namespace std;

#define all(c) (c).begin(), (c).end()
int ni() { int val; scanf("%i", &val); return val; }
pair<int, int> npi() { pair<int, int> val; scanf("%i %i", &val.first, &val.second); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
char nc() { char val; do { scanf("%c", &val); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { scanf("%c", &val); } while (false); return val; }
string ns() { static char buff[1024 * 2000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }

int n;
int sm[1 << 19];
int sum(int p)
{
  int result = 0;
  for (; p >= 0; p = (p & (p + 1)) - 1)
    result += sm[p];
  return result;
}
int sum(int l, int r)
{
  return sum(r) - sum(l - 1);
}
void inc(int p, int val)
{
  for (; p <= n; p = (p | (p + 1)))
    sm[p] += val;
}

const int maxn = 2 * 100000 + 1;
vector<int> gr[maxn];

vector<int> vs[3];
vector<int> color;
vector<int> used, order;
void go(int v, int d) {
  used[v] = 1;
  vs[d].push_back(v);
  if (d == 2) return;
  for (auto u : gr[v]) if (used[u] == 0) {
    go(u, d + 1);
  }
}

void dfs(int v) {
  used[v] = 1;
  order.emplace_back(v);
  for (auto u : gr[v]) if (used[u] == 0) {
    dfs(u);
  }
}

int main()
{
  n = ni();
  for (int i = 0; i < n - 1; ++i) {
    auto u = ni()-1, v = ni()-1;
    gr[u].emplace_back(v);
    gr[v].emplace_back(u);
  }

  used.assign(n, 0);
  dfs(0);
  used.assign(n, 0);
  color.assign(n, 0);
  random_shuffle(all(order));
  for (int i = 0; i < n; ++i) {
    auto q = order[i];
    if (color[q] == 0) {
      vs[0].clear(); vs[1].clear(); vs[2].clear();
      go(q, 0);
      for(int k = 0; k < 3; ++k) for (int j = 0; j < vs[k].size(); ++j){
        auto col = color[vs[k][j]];
        if (col)
          inc(col, 1);
      }

      // color I
      int l = 1, r = n;
      while (l < r) {
        auto mid = (l + r) / 2;
        auto sm = sum(mid);
        if (sm == mid)
          l = mid + 1;
        else
          r = mid;
      }
      color[q] = l;
      inc(l, 1);
      for (int j = 0; j < vs[2].size(); ++j) {
        auto col = color[vs[2][j]];
        if (col)
        {
          inc(col, -1);
          used[vs[2][j]] = 0;
        }
      }

      for (int j = 0; j < vs[1].size(); ++j) if (color[vs[1][j]] == 0){
        int l = 1, r = n;
        while (l < r) {
          auto mid = (l + r) / 2;
          auto sm = sum(mid);
          if (sm == mid)
            l = mid + 1;
          else
            r = mid;
        }
        color[vs[1][j]] = l;
        inc(l, 1);
      }

      for (int k = 0; k < 2; ++k) for (int j = 0; j < vs[k].size(); ++j) {
        auto v = vs[k][j];
        if (color[v])
          inc(color[v], -1);
        used[v] = 0;
      }
    }
  }

  int max_color = 0;
  for (int i = 0; i < n; ++i)
    max_color = max(max_color, color[i]);

  printf("%i\n", max_color);
  for (int i = 0; i < n; ++i)
    printf("%i ", color[i]);

  return 0;
}


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

#define all(c) (c).begin(), (c).end()
int ni() { int val; scanf("%i", &val); return val; }
int64_t nll() { int64_t val; scanf("%I64d", &val); return val; }
char nc() { char val; do { val = getchar(); } while (val == ' ' || val == '\r' || val == '\n'); return val; }
char ncs() { char val; do { val = getchar(); } while (false); return val; }
string ns() { static char buff[1024 * 4000]; scanf("%s", buff); return string{ buff }; }
int64_t gcd(int64_t a, int64_t b) { while (b) { auto tmp = a % b; a = b; b = tmp; } return a; }

vector<int> gr[200007];
int c[200007];
int ans = 0;

void dfs(int u, int a, int b)
{
  c[u] = a;
  ans = max(ans, a);
  int st = 1;
  for (auto v : gr[u])
  {
    if (v == b)	continue;
    while (st == a || st == c[b])
      ++st;
    dfs(v, st, u);
    ++st;
  }
}

int main()
{
  auto n = ni();
  for (int i = 1; i < n; i++)
  {
    auto u = ni(), v = ni();
    gr[u].push_back(v);
    gr[v].push_back(u);
  }

  dfs(1, 1, 0);
  printf("%d\n", ans);
  for (int i = 1; i <= n; i++){
    printf("%d%c", c[i], i == n ? '\n' : ' ');
  }
  return 0;
}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <cstring>
#include <stdio.h>
#include <queue>
using namespace std;

struct orc{
	int num;
	int x;
	int y;
};

bool myfunction (orc i,orc j) { return (i.x<j.x); }

struct Comp1
{
	bool operator()(const orc& str1, const orc& str2)
	{
		return str1.y < str2.y;
	}
};
#define nash  %1000000007

//while(r - l != 0)
//    {
//        int64 mid =  MID(r,l);
//        if(mid * (mid + 1) / 2 >= n) r = mid;
//        else l = mid + 1;
//    }

int n;
vector<int> vec[200010];
int q[200010];

int c[200010];
bool av[200010];

void color(int res){

	c[1] = 1;

	for(int i=2; i<=n; i++){

		for(int j =0; j<vec[i].size(); j++){
			if(!av[ c[vec[i][j] ]])
				av[ c[ vec[i][j] ] ]= true;

			for(int z=0; z<vec[vec[i][j]].size(); z++){
				if(!av[ c[ vec[vec[i][j]]  [z] ] ] )
					av[c [ vec[vec[i][j]]  [z]  ]] = true;
			}
		}

		for(int j = 1; j<=res; j++){
			if(!av[j])
				c[i]=j;

		}

		for(int j =0; j<=res; j++){
			av[j]=false;
		}

	}

}

int main(){

	cin>>n;

	for(int i=1; i<n; i++){
		int a,b;
		scanf("%d%d", &a,&b);

		vec[a].push_back(b);
		vec[b].push_back(a);

	}

	int res =0;
	for(int i=1; i<=n; i++){
		int si = vec[i].size();
		res = max(res, si );
	}

	color(res+1);

	cout<<res+1<<endl;
	for(int i =1; i<=n; i++){
		cout<<c[i]<<" ";
		if(c[i] == 0){
			cout<<vec[1000000][5];
		}
	}
}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <cstring>
#include <stdio.h>
#include <queue>
using namespace std;

struct orc{
	int num;
	int x;
	int y;
};

bool myfunction (orc i,orc j) { return (i.x<j.x); }

struct Comp1
{
	bool operator()(const orc& str1, const orc& str2)
	{
		return str1.y < str2.y;
	}
};
#define nash  %1000000007

//while(r - l != 0)
//    {
//        int64 mid =  MID(r,l);
//        if(mid * (mid + 1) / 2 >= n) r = mid;
//        else l = mid + 1;
//    }

int n;
vector<int> vec[200010];
int q[200010];

int c[200010];
bool av[200010];
	int res =0;

void color(int a, int ci, int p ){

//	cout<<res<<endl;
//	for(int i =1; i<=n; i++){
//	//	if(c[i]==0) c[i]=res;
//		cout<<c[i]<<" ";
//	}
//	cout<<endl;
	int g = ci;

	for(int i=0; i<vec[a].size(); i++){

		int k = vec[a][i] ;

		if(!av[ k ]){
			while( g==ci || g==p  ) g=(g+1)%res;

			c[ k ] = g;
			av[k] = true;
			color( k ,  g, ci  );
			g=(g+1)%res;
		}

	}
}

int main(){

	cin>>n;

	for(int i=1; i<n; i++){
		int a,b;
		scanf("%d%d", &a,&b);

		vec[a].push_back(b);
		vec[b].push_back(a);

	}

	for(int i=1; i<=n; i++){
		int si = vec[i].size();
		res = max(res, si );
	}

	res++;
	c[1] = 1;
	av[1] = true;

	color(1,1, -1 );

	cout<<res<<endl;
	for(int i =1; i<=n; i++){
		if(c[i]==0) c[i]=res;
		cout<<c[i]<<" ";
	}
	cout<<endl;
}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <cstring>
#include <stdio.h>
#include <queue>
using namespace std;

struct orc{
	int num;
	int x;
	int y;
};

bool myfunction (orc i,orc j) { return (i.x<j.x); }

struct Comp1
{
	bool operator()(const orc& str1, const orc& str2)
	{
		return str1.y < str2.y;
	}
};
#define nash  %1000000007

//while(r - l != 0)
//    {
//        int64 mid =  MID(r,l);
//        if(mid * (mid + 1) / 2 >= n) r = mid;
//        else l = mid + 1;
//    }

int n;
vector<int> vec[200010];
int q[200010];

int c[200010];
bool av[200010];

void color(int res){

	c[1] = 1;

	for(int i=2; i<=n; i++){

		for(int j =0; j<vec[i].size(); j++){
			if(!av[ c[vec[i][j] ]])
				av[ c[ vec[i][j] ] ]= true;

			for(int z=0; z<vec[vec[i][j]].size(); z++){
				if(!av[ c[ vec[vec[i][j]]  [z] ] ] )
					av[c [ vec[vec[i][j]]  [z]  ]] = true;
			}
		}

		for(int j = 1; j<=res; j++){
			if(!av[j])
				c[i]=j;

		}

		for(int j =0; j<vec[i].size(); j++){
			if(av[ c[vec[i][j] ]])
				av[ c[vec[i][j] ]] = false;

			for(int z=0; z<vec[vec[i][j]].size(); z++){
				if(av[ c[ vec[vec[i][j]]  [z] ] ] )
					av[ c[ vec[vec[i][j]]  [z] ] ] = false;
			}
		}

	}

}

int main(){

	cin>>n;

	for(int i=1; i<n; i++){
		int a,b;
		scanf("%d%d", &a,&b);

		vec[a].push_back(b);
		vec[b].push_back(a);

	}

	int res =0;
	for(int i=1; i<=n; i++){
		int si = vec[i].size();
		res = max(res, si );
	}

	color(res+1);

	cout<<res+1<<endl;
	for(int i =1; i<=n; i++){
		cout<<c[i]<<" ";
	}
}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <cstring>
#include <stdio.h>
#include <queue>
using namespace std;

struct orc{
	int num;
	int x;
	int y;
};

bool myfunction (orc i,orc j) { return (i.x<j.x); }

struct Comp1
{
	bool operator()(const orc& str1, const orc& str2)
	{
		return str1.y < str2.y;
	}
};
#define nash  %1000000007

//while(r - l != 0)
//    {
//        int64 mid =  MID(r,l);
//        if(mid * (mid + 1) / 2 >= n) r = mid;
//        else l = mid + 1;
//    }

int n;
vector<int> vec[200001];
int q[200001];

int c[200001];
bool av[200001];

void color(int res){

	c[1] = 1;

	for(int i=2; i<=n; i++){

		for(int j =0; j<vec[i].size(); j++){
			av[ c[ vec[i][j] ] ]= true;
			for(int z=0; z<vec[vec[i][j]].size(); z++){
				av[c [ vec[vec[i][j]]  [z]  ]] = true;
			}
		}

		for(int j = 1; j<=res; j++){
			if(!av[j])
				c[i]=j;

		}

		cout<<c[i]<<endl;
			for(int j =0; j<vec[i].size(); j++){
			av[ c[vec[i][j] ]] = false;
			for(int z=0; z<vec[vec[i][j]].size(); z++){
				av[ c[ vec[vec[i][j]]  [z] ] ] = false;
			}
		}

	}

}

int main(){

	cin>>n;

	for(int i=1; i<n; i++){
		int a,b;
		scanf("%d%d", &a,&b);

		vec[a].push_back(b);
		vec[b].push_back(a);

	}

	int res =0;
	for(int i=1; i<=n; i++){
		int si = vec[i].size();
		res = max(res, si );
	}

	color(res+1);

	cout<<res+1<<endl;
	for(int i =1; i<=n; i++){
		cout<<c[i]<<" ";
	}
}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <cstring>
#include <stdio.h>
#include <queue>
using namespace std;

struct orc{
	int num;
	int x;
	int y;
};

bool myfunction (orc i,orc j) { return (i.x<j.x); }

struct Comp1
{
	bool operator()(const orc& str1, const orc& str2)
	{
		return str1.y < str2.y;
	}
};
#define nash  %1000000007

//while(r - l != 0)
//    {
//        int64 mid =  MID(r,l);
//        if(mid * (mid + 1) / 2 >= n) r = mid;
//        else l = mid + 1;
//    }

int n;
vector<int> vec[200010];
int q[200010];

int c[200010];
bool av[200010];

void color(int res){

	c[1] = 1;

	for(int i=2; i<=n; i++){

		for(int j =0; j<vec[i].size(); j++){
			if(!av[ c[vec[i][j] ]])
				av[ c[ vec[i][j] ] ]= true;

			for(int z=0; z<vec[vec[i][j]].size(); z++){
				if(!av[ c[ vec[vec[i][j]]  [z] ] ] )
					av[c [ vec[vec[i][j]]  [z]  ]] = true;
			}
		}

		for(int j = 1; j<=res; j++){
			if(!av[j])
				c[i]=j;

		}

		for(int j =0; j<=res; j++){
			av[j]=false;
		}

	}

}

int main(){

	cin>>n;

	for(int i=1; i<n; i++){
		int a,b;
		scanf("%d%d", &a,&b);

		vec[a].push_back(b);
		vec[b].push_back(a);

	}

	int res =0;
	for(int i=1; i<=n; i++){
		int si = vec[i].size();
		res = max(res, si );
	}

	color(res+1);

	cout<<res+1<<endl;
	for(int i =1; i<=n; i++){
		cout<<c[i]<<" ";
	}
}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <cstring>
#include <stdio.h>
#include <queue>
using namespace std;

struct orc{
	int num;
	int x;
	int y;
};

bool myfunction (orc i,orc j) { return (i.x<j.x); }

struct Comp1
{
	bool operator()(const orc& str1, const orc& str2)
	{
		return str1.y < str2.y;
	}
};
#define nash  %1000000007

//while(r - l != 0)
//    {
//        int64 mid =  MID(r,l);
//        if(mid * (mid + 1) / 2 >= n) r = mid;
//        else l = mid + 1;
//    }

int n;
vector<int> vec[200001];
int q[200001];

int c[200001];
bool av[200001];

void color(int res){

	c[1] = 1;

	for(int i=2; i<=n; i++){

		for(int j =0; j<vec[i].size(); j++){
			av[ vec[i][j] ] = true;
		}

		for(int j = 1; j<=res; j++){
			if(!av[j])
				c[i]=j;
		}

		for(int j =0; j<vec[i].size(); j++){
			av[ vec[i][j] ] = false;
		}

	}

}

int main(){

	cin>>n;

	for(int i=1; i<n; i++){
		int a,b;
		scanf("%d%d", &a,&b);

		vec[a].push_back(b);
		vec[b].push_back(a);

	}

	int res =0;
	for(int i=1; i<=n; i++){
		int si = vec[i].size();
		res = max(res, si );
	}

	color(res+1);

	cout<<res+1<<endl;
	for(int i =1; i<=n; i++){
		cout<<c[i]<<" ";
	}
}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <cstring>
#include <stdio.h>
#include <queue>
using namespace std;

struct orc{
	int num;
	int x;
	int y;
};

bool myfunction (orc i,orc j) { return (i.x<j.x); }

struct Comp1
{
	bool operator()(const orc& str1, const orc& str2)
	{
		return str1.y < str2.y;
	}
};
#define nash  %1000000007

//while(r - l != 0)
//    {
//        int64 mid =  MID(r,l);
//        if(mid * (mid + 1) / 2 >= n) r = mid;
//        else l = mid + 1;
//    }

int n;
vector<int> vec[200001];
int q[200001];

int c[200001];
bool av[200001];

void color(int res){

	c[1] = 1;

	for(int i=2; i<=n; i++){

		for(int j =0; j<vec[i].size(); j++){
			if(!av[ c[vec[i][j] ]])
				av[ c[ vec[i][j] ] ]= true;
			for(int z=0; z<vec[vec[i][j]].size(); z++){
				if(!av[ c[ vec[vec[i][j]]  [z] ] ] )
					av[c [ vec[vec[i][j]]  [z]  ]] = true;
			}
		}

		for(int j = 1; j<=res; j++){
			if(!av[j])
				c[i]=j;

		}

		for(int j =0; j<vec[i].size(); j++){
			if(av[ c[vec[i][j] ]])
				av[ c[vec[i][j] ]] = false;

			for(int z=0; z<vec[vec[i][j]].size(); z++){
				if(av[ c[ vec[vec[i][j]]  [z] ] ] )
					av[ c[ vec[vec[i][j]]  [z] ] ] = false;
			}
		}

	}

}

int main(){

	cin>>n;

	for(int i=1; i<n; i++){
		int a,b;
		scanf("%d%d", &a,&b);

		vec[a].push_back(b);
		vec[b].push_back(a);

	}

	int res =0;
	for(int i=1; i<=n; i++){
		int si = vec[i].size();
		res = max(res, si );
	}

	color(res+1);

	cout<<res+1<<endl;
	for(int i =1; i<=n; i++){
		cout<<c[i]<<" ";
	}
}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <cstring>
#include <stdio.h>
#include <queue>
using namespace std;

struct orc{
	int num;
	int x;
	int y;
};

bool myfunction (orc i,orc j) { return (i.x<j.x); }

struct Comp1
{
	bool operator()(const orc& str1, const orc& str2)
	{
		return str1.y < str2.y;
	}
};
#define nash  %1000000007

//while(r - l != 0)
//    {
//        int64 mid =  MID(r,l);
//        if(mid * (mid + 1) / 2 >= n) r = mid;
//        else l = mid + 1;
//    }

int n;
vector<int> vec[200001];
int q[200001];

int c[200001];
bool av[200001];

void color(int res){

	c[1] = 1;

	for(int i=2; i<=n; i++){

		for(int j =0; j<vec[i].size(); j++){
			av[ c[ vec[i][j] ] ]= true;
			for(int z=0; z<vec[vec[i][j]].size(); z++){
				av[c [ vec[vec[i][j]]  [z]  ]] = true;
			}
		}

		for(int j = 1; j<=res; j++){
			if(!av[j])
				c[i]=j;

		}

			for(int j =0; j<vec[i].size(); j++){
			av[ c[vec[i][j] ]] = false;
			for(int z=0; z<vec[vec[i][j]].size(); z++){
				av[ c[ vec[vec[i][j]]  [z] ] ] = false;
			}
		}

	}

}

int main(){

	cin>>n;

	for(int i=1; i<n; i++){
		int a,b;
		scanf("%d%d", &a,&b);

		vec[a].push_back(b);
		vec[b].push_back(a);

	}

	int res =0;
	for(int i=1; i<=n; i++){
		int si = vec[i].size();
		res = max(res, si );
	}

	color(res+1);

	cout<<res+1<<endl;
	for(int i =1; i<=n; i++){
		cout<<c[i]<<" ";
	}
}


#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <cstring>
#include <stdio.h>
#include <queue>
using namespace std;

struct orc{
	int num;
	int x;
	int y;
};

bool myfunction (orc i,orc j) { return (i.x<j.x); }

struct Comp1
{
	bool operator()(const orc& str1, const orc& str2)
	{
		return str1.y < str2.y;
	}
};
#define nash  %1000000007

//while(r - l != 0)
//    {
//        int64 mid =  MID(r,l);
//        if(mid * (mid + 1) / 2 >= n) r = mid;
//        else l = mid + 1;
//    }

int n;
vector<int> vec[200010];
int q[200001];

int c[200010];
bool av[200010];

void color(int res){

	c[1] = 1;

	for(int i=2; i<=n; i++){

		for(int j =0; j<vec[i].size(); j++){
			if(!av[ c[vec[i][j] ]])
				av[ c[ vec[i][j] ] ]= true;

			for(int z=0; z<vec[vec[i][j]].size(); z++){
				if(!av[ c[ vec[vec[i][j]]  [z] ] ] )
					av[c [ vec[vec[i][j]]  [z]  ]] = true;
			}
		}

		for(int j = 1; j<=res; j++){
			if(!av[j])
				c[i]=j;

		}

		for(int j =0; j<vec[i].size(); j++){
			if(av[ c[vec[i][j] ]])
				av[ c[vec[i][j] ]] = false;

			for(int z=0; z<vec[vec[i][j]].size(); z++){
				if(av[ c[ vec[vec[i][j]]  [z] ] ] )
					av[ c[ vec[vec[i][j]]  [z] ] ] = false;
			}
		}

	}

}

int main(){

	cin>>n;

	for(int i=1; i<n; i++){
		int a,b;
		scanf("%d%d", &a,&b);

		vec[a].push_back(b);
		vec[b].push_back(a);

	}

	int res =0;
	for(int i=1; i<=n; i++){
		int si = vec[i].size();
		res = max(res, si );
	}

	color(res+1);

	cout<<res+1<<endl;
	for(int i =1; i<=n; i++){
		cout<<c[i]<<" ";
	}
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll       long long
#define ull      unsigned long long
#define ld       long double
#define pii      pair<int,int>
#define pll      pair<ll,ll>
#define vi       vector<int>
#define vll      vector<ll>
#define vc       vector<char>
#define vs       vector<string>
#define vpii     vector< pair<int,int> >
#define vpll     vector< pair<ll,ll> >
#define ppll     pair< ll,pll >
#define pllp     pair< pll,ll >
#define stll     stack<ll>
#define qll      queue<ll>
#define pqll     priority_queue<ll>
#define mppll    map<pll,ll>
#define mpii     map<int,int>
#define mpll     map<ll,ll>
#define mpss     map<string,string>
#define mpsll    map<string,ll>
#define mplls    map<ll,string>
#define umpii    unordered_map<int,int>
#define umll     unordered_map<ll,ll>
#define umpss    unordered_map<string,string>
#define umpsll   unordered_map<string,ll>
#define umplls   unordered_map<ll,string>
#define umap     unordered_map
#define uset     unordered_set
#define PQ       priority_queue

#define rep(i,n)        for(i=0;i<n;i++)
#define itfor(i, c)     for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define printa(a,L,R)   for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a)       printa(a,0,a.size())
#define print2d(a,r,c)  for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb              push_back
#define MP              make_pair
#define UB              upper_bound
#define LB              lower_bound
#define SQ(x)           ((x)*(x))
#define issq(x)         (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
#define F               first
#define S               second
#define mem(a,x)        memset(a,x,sizeof(a))
#define inf             0x3f3f3f3f
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define gamma           0.5772156649
#define nl              "\n"
#define lg(r,n)         (int)(log2(n)/log2(r))
#define sf(a)           scanf("%d",&a)
#define sfl(a)          scanf("%I64d",&a)
#define sfc(a)          scanf("%c",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sffl(a,b)       scanf("%I64d %I64d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%I64d %I64d %I64d",&a,&b,&c)
#define pf              printf
#define pfi(a)          pf("%d\n",&a)
#define pfl(a)          pf("%I64d\n",&a)
#define _ccase          printf("Case %d: ",++cs)
#define _case           cout<<"Case "<<++cs<<": "
#define debug(x)        cout<<#x"="<<(x)<<nl

#define rev(v)              reverse(v.begin(),v.end())
#define srt(v)              sort(v.begin(),v.end())
#define grtsrt(v)           sort(v.begin(),v.end(),greater<int>())
#define all(v)              v.begin(),v.end()
#define mnv(v)              *min_element(v.begin(),v.end())
#define mxv(v)              *max_element(v.begin(),v.end())
#define countv(v,a)         count(v.begin(),v.end(),a)
#define toint(a)            atoi(a.c_str())
#define midlr               mid=b+((e-b)>>1),l=n<<1,r=n<<1|1
#define fast                ios_base::sync_with_stdio(false),cin.tie(NULL)
string  tostr(int n)        {stringstream rr;rr<<n;return rr.str();}
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod=1e9+7;
//ll qpow(ll n,ll k)          {ll ans=1;n%=mod;while(k){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}
const int mxn=2e5+9;
const ld  eps=1e-9;
vll g[mxn];
ll k=1,col[mxn],st;
void dfs(ll u,ll pre1,ll pre2)
{
    if(u==st) col[u]=k++;
    else if(pre1==st) col[u]=k++;
    else{
        if(col[pre1]!=1&&col[pre2]!=1) col[u]=1;
        else if(col[pre1]!=2&&col[pre2]!=2) col[u]=2;
        else col[u]=3;
    }
    for(auto v:g[u]){
        if(!col[v]) dfs(v,u,pre1);
    }
}
int main()
{
    fast;
    ll i,j,k,n,m,mx=-1,u,v;
    cin>>n;
    for(i=0;i<n-1;i++){
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for(i=1;i<=n;i++){
        if((ll)g[i].size()>mx){
            mx=(ll)g[i].size();
            st=i;
        }
    }
    cout<<mx+1<<nl;
    dfs(st,0,0);
    for(i=1;i<=n;i++) cout<<col[i]<<' ';
    return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll       long long
#define ull      unsigned long long
#define ld       long double
#define pii      pair<int,int>
#define pll      pair<ll,ll>
#define vi       vector<int>
#define vll      vector<ll>
#define vc       vector<char>
#define vs       vector<string>
#define vpii     vector< pair<int,int> >
#define vpll     vector< pair<ll,ll> >
#define ppll     pair< ll,pll >
#define pllp     pair< pll,ll >
#define stll     stack<ll>
#define qll      queue<ll>
#define pqll     priority_queue<ll>
#define mppll    map<pll,ll>
#define mpii     map<int,int>
#define mpll     map<ll,ll>
#define mpss     map<string,string>
#define mpsll    map<string,ll>
#define mplls    map<ll,string>
#define umpii    unordered_map<int,int>
#define umll     unordered_map<ll,ll>
#define umpss    unordered_map<string,string>
#define umpsll   unordered_map<string,ll>
#define umplls   unordered_map<ll,string>
#define umap     unordered_map
#define uset     unordered_set
#define PQ       priority_queue

#define rep(i,n)        for(i=0;i<n;i++)
#define itfor(i, c)     for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define printa(a,L,R)   for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a)       printa(a,0,a.size())
#define print2d(a,r,c)  for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb              push_back
#define MP              make_pair
#define UB              upper_bound
#define LB              lower_bound
#define SQ(x)           ((x)*(x))
#define issq(x)         (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
#define F               first
#define S               second
#define mem(a,x)        memset(a,x,sizeof(a))
#define inf             0x3f3f3f3f
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define gamma           0.5772156649
#define nl              "\n"
#define lg(r,n)         (int)(log2(n)/log2(r))
#define sf(a)           scanf("%d",&a)
#define sfl(a)          scanf("%I64d",&a)
#define sfc(a)          scanf("%c",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sffl(a,b)       scanf("%I64d %I64d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%I64d %I64d %I64d",&a,&b,&c)
#define pf              printf
#define pfi(a)          pf("%d\n",&a)
#define pfl(a)          pf("%I64d\n",&a)
#define _ccase          printf("Case %d: ",++cs)
#define _case           cout<<"Case "<<++cs<<": "
#define debug(x)        cout<<#x"="<<(x)<<nl

#define rev(v)              reverse(v.begin(),v.end())
#define srt(v)              sort(v.begin(),v.end())
#define grtsrt(v)           sort(v.begin(),v.end(),greater<int>())
#define all(v)              v.begin(),v.end()
#define mnv(v)              *min_element(v.begin(),v.end())
#define mxv(v)              *max_element(v.begin(),v.end())
#define countv(v,a)         count(v.begin(),v.end(),a)
#define toint(a)            atoi(a.c_str())
#define midlr               mid=b+((e-b)>>1),l=n<<1,r=n<<1|1
#define fast                ios_base::sync_with_stdio(false),cin.tie(NULL)
string  tostr(int n)        {stringstream rr;rr<<n;return rr.str();}
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod=1e9+7;
//ll qpow(ll n,ll k)          {ll ans=1;n%=mod;while(k){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}
const int mxn=2e5+9;
const ld  eps=1e-9;
vll g[mxn];
ll col[mxn];
set<ll>se;
void dfs(ll u,ll now,ll pre)
{
    se.insert(now);
    col[u]=now;
    ll a=1;
    for(auto v:g[u]){
        while(a==now||a==pre) a++;
        if(!col[v]) dfs(v,a,now),a++;
    }
}
int main()
{
    fast;
    ll i,j,k,n,m,mx=-1,u,v;
    cin>>n;
    for(i=0;i<n-1;i++){
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1,1,0);
    cout<<se.size()<<nl;
    for(i=1;i<=n;i++) cout<<col[i]<<' ';
    return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll       long long
#define ull      unsigned long long
#define ld       long double
#define pii      pair<int,int>
#define pll      pair<ll,ll>
#define vi       vector<int>
#define vll      vector<ll>
#define vc       vector<char>
#define vs       vector<string>
#define vpii     vector< pair<int,int> >
#define vpll     vector< pair<ll,ll> >
#define ppll     pair< ll,pll >
#define pllp     pair< pll,ll >
#define stll     stack<ll>
#define qll      queue<ll>
#define pqll     priority_queue<ll>
#define mppll    map<pll,ll>
#define mpii     map<int,int>
#define mpll     map<ll,ll>
#define mpss     map<string,string>
#define mpsll    map<string,ll>
#define mplls    map<ll,string>
#define umpii    unordered_map<int,int>
#define umll     unordered_map<ll,ll>
#define umpss    unordered_map<string,string>
#define umpsll   unordered_map<string,ll>
#define umplls   unordered_map<ll,string>
#define umap     unordered_map
#define uset     unordered_set
#define PQ       priority_queue

#define rep(i,n)        for(i=0;i<n;i++)
#define itfor(i, c)     for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define printa(a,L,R)   for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a)       printa(a,0,a.size())
#define print2d(a,r,c)  for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb              push_back
#define MP              make_pair
#define UB              upper_bound
#define LB              lower_bound
#define SQ(x)           ((x)*(x))
#define issq(x)         (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
#define F               first
#define S               second
#define mem(a,x)        memset(a,x,sizeof(a))
#define inf             0x3f3f3f3f
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define gamma           0.5772156649
#define nl              "\n"
#define lg(r,n)         (int)(log2(n)/log2(r))
#define sf(a)           scanf("%d",&a)
#define sfl(a)          scanf("%I64d",&a)
#define sfc(a)          scanf("%c",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sffl(a,b)       scanf("%I64d %I64d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%I64d %I64d %I64d",&a,&b,&c)
#define pf              printf
#define pfi(a)          pf("%d\n",&a)
#define pfl(a)          pf("%I64d\n",&a)
#define _ccase          printf("Case %d: ",++cs)
#define _case           cout<<"Case "<<++cs<<": "
#define debug(x)        cout<<#x"="<<(x)<<nl

#define rev(v)              reverse(v.begin(),v.end())
#define srt(v)              sort(v.begin(),v.end())
#define grtsrt(v)           sort(v.begin(),v.end(),greater<int>())
#define all(v)              v.begin(),v.end()
#define mnv(v)              *min_element(v.begin(),v.end())
#define mxv(v)              *max_element(v.begin(),v.end())
#define countv(v,a)         count(v.begin(),v.end(),a)
#define toint(a)            atoi(a.c_str())
#define midlr               mid=b+((e-b)>>1),l=n<<1,r=n<<1|1
#define fast                ios_base::sync_with_stdio(false),cin.tie(NULL)
string  tostr(int n)        {stringstream rr;rr<<n;return rr.str();}
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod=1e9+7;
//ll qpow(ll n,ll k)          {ll ans=1;n%=mod;while(k){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}
const int mxn=2e5+9;
const ld  eps=1e-9;
vll g[mxn];
ll k=1,col[mxn],st;
bool vis[mxn];
void dfs(ll u,ll pre1,ll pre2)
{
    vis[u]=1;
    if(u==st) col[u]=k++;
    else if(pre1==st) col[u]=k++;
    else{
        if(col[pre1]!=1&&col[pre2]!=1) col[u]=1;
        else if(col[pre1]!=2&&col[pre2]!=2) col[u]=2;
        else col[u]=3;
    }
    for(auto v:g[u]){
        if(!vis[v]) dfs(v,u,pre1);
    }
}
int main()
{
    fast;
    ll i,j,k,n,m,mx=-1,u,v;
    cin>>n;
    for(i=0;i<n-1;i++){
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for(i=1;i<=n;i++){
        if((ll)g[i].size()>mx){
            mx=(ll)g[i].size();
            st=i;
        }
    }
    cout<<mx+1<<nl;
    dfs(st,0,0);
    for(i=1;i<=n;i++) cout<<col[i]<<' ';
    return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll       long long
#define ull      unsigned long long
#define ld       long double
#define pii      pair<int,int>
#define pll      pair<ll,ll>
#define vi       vector<int>
#define vll      vector<ll>
#define vc       vector<char>
#define vs       vector<string>
#define vpii     vector< pair<int,int> >
#define vpll     vector< pair<ll,ll> >
#define ppll     pair< ll,pll >
#define pllp     pair< pll,ll >
#define stll     stack<ll>
#define qll      queue<ll>
#define pqll     priority_queue<ll>
#define mppll    map<pll,ll>
#define mpii     map<int,int>
#define mpll     map<ll,ll>
#define mpss     map<string,string>
#define mpsll    map<string,ll>
#define mplls    map<ll,string>
#define umpii    unordered_map<int,int>
#define umll     unordered_map<ll,ll>
#define umpss    unordered_map<string,string>
#define umpsll   unordered_map<string,ll>
#define umplls   unordered_map<ll,string>
#define umap     unordered_map
#define uset     unordered_set
#define PQ       priority_queue

#define rep(i,n)        for(i=0;i<n;i++)
#define itfor(i, c)     for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define printa(a,L,R)   for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a)       printa(a,0,a.size())
#define print2d(a,r,c)  for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb              push_back
#define MP              make_pair
#define UB              upper_bound
#define LB              lower_bound
#define SQ(x)           ((x)*(x))
#define issq(x)         (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
#define F               first
#define S               second
#define mem(a,x)        memset(a,x,sizeof(a))
#define inf             0x3f3f3f3f
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define gamma           0.5772156649
#define nl              "\n"
#define lg(r,n)         (int)(log2(n)/log2(r))
#define sf(a)           scanf("%d",&a)
#define sfl(a)          scanf("%I64d",&a)
#define sfc(a)          scanf("%c",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sffl(a,b)       scanf("%I64d %I64d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%I64d %I64d %I64d",&a,&b,&c)
#define pf              printf
#define pfi(a)          pf("%d\n",&a)
#define pfl(a)          pf("%I64d\n",&a)
#define _ccase          printf("Case %d: ",++cs)
#define _case           cout<<"Case "<<++cs<<": "
#define debug(x)        cout<<#x"="<<(x)<<nl

#define rev(v)              reverse(v.begin(),v.end())
#define srt(v)              sort(v.begin(),v.end())
#define grtsrt(v)           sort(v.begin(),v.end(),greater<int>())
#define all(v)              v.begin(),v.end()
#define mnv(v)              *min_element(v.begin(),v.end())
#define mxv(v)              *max_element(v.begin(),v.end())
#define countv(v,a)         count(v.begin(),v.end(),a)
#define toint(a)            atoi(a.c_str())
#define midlr               mid=b+((e-b)>>1),l=n<<1,r=n<<1|1
#define fast                ios_base::sync_with_stdio(false),cin.tie(NULL)
string  tostr(int n)        {stringstream rr;rr<<n;return rr.str();}
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod=1e9+7;
//ll qpow(ll n,ll k)          {ll ans=1;n%=mod;while(k){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}
const int mxn=1e5+9;
const ld  eps=1e-9;
vll g[mxn];
ll k=1,col[mxn],st;
bool vis[mxn];
void dfs(ll u,ll pre1,ll pre2)
{
    vis[u]=1;
    if(u==st) col[u]=k++;
    else if(pre1==st) col[u]=k++;
    else{
        if(col[pre1]!=1&&col[pre2]!=1) col[u]=1;
        else if(col[pre1]!=2&&col[pre2]!=2) col[u]=2;
        else col[u]=3;
    }
    for(auto v:g[u]){
        if(!vis[v]) dfs(v,u,pre1);
    }
}
int main()
{
    fast;
    ll i,j,k,n,m,mx=-1,u,v;
    cin>>n;
    for(i=0;i<n-1;i++){
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    for(i=1;i<=n;i++){
        if((ll)g[i].size()>mx){
            mx=(ll)g[i].size();
            st=i;
        }
    }
    cout<<mx+1<<nl;
    dfs(st,0,0);
    for(i=1;i<=n;i++) cout<<col[i]<<' ';
    return 0;
}


#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll       long long
#define ull      unsigned long long
#define ld       long double
#define pii      pair<int,int>
#define pll      pair<ll,ll>
#define vi       vector<int>
#define vll      vector<ll>
#define vc       vector<char>
#define vs       vector<string>
#define vpii     vector< pair<int,int> >
#define vpll     vector< pair<ll,ll> >
#define ppll     pair< ll,pll >
#define pllp     pair< pll,ll >
#define stll     stack<ll>
#define qll      queue<ll>
#define pqll     priority_queue<ll>
#define mppll    map<pll,ll>
#define mpii     map<int,int>
#define mpll     map<ll,ll>
#define mpss     map<string,string>
#define mpsll    map<string,ll>
#define mplls    map<ll,string>
#define umpii    unordered_map<int,int>
#define umll     unordered_map<ll,ll>
#define umpss    unordered_map<string,string>
#define umpsll   unordered_map<string,ll>
#define umplls   unordered_map<ll,string>
#define umap     unordered_map
#define uset     unordered_set
#define PQ       priority_queue

#define rep(i,n)        for(i=0;i<n;i++)
#define itfor(i, c)     for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define printa(a,L,R)   for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define printv(a)       printa(a,0,a.size())
#define print2d(a,r,c)  for(int i=0;i<r;i++) for(int j=0;j<c;j++) cout<<a[i][j]<<(j==c-1?'\n':' ')
#define pb              push_back
#define MP              make_pair
#define UB              upper_bound
#define LB              lower_bound
#define SQ(x)           ((x)*(x))
#define issq(x)         (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
#define F               first
#define S               second
#define mem(a,x)        memset(a,x,sizeof(a))
#define inf             0x3f3f3f3f
#define PI              3.14159265358979323846
#define E               2.71828182845904523536
#define gamma           0.5772156649
#define nl              "\n"
#define lg(r,n)         (int)(log2(n)/log2(r))
#define sf(a)           scanf("%d",&a)
#define sfl(a)          scanf("%I64d",&a)
#define sfc(a)          scanf("%c",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sffl(a,b)       scanf("%I64d %I64d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%I64d %I64d %I64d",&a,&b,&c)
#define pf              printf
#define pfi(a)          pf("%d\n",&a)
#define pfl(a)          pf("%I64d\n",&a)
#define _ccase          printf("Case %d: ",++cs)
#define _case           cout<<"Case "<<++cs<<": "
#define debug(x)        cout<<#x"="<<(x)<<nl

#define rev(v)              reverse(v.begin(),v.end())
#define srt(v)              sort(v.begin(),v.end())
#define grtsrt(v)           sort(v.begin(),v.end(),greater<int>())
#define all(v)              v.begin(),v.end()
#define mnv(v)              *min_element(v.begin(),v.end())
#define mxv(v)              *max_element(v.begin(),v.end())
#define countv(v,a)         count(v.begin(),v.end(),a)
#define toint(a)            atoi(a.c_str())
#define midlr               mid=b+((e-b)>>1),l=n<<1,r=n<<1|1
#define fast                ios_base::sync_with_stdio(false),cin.tie(NULL)
string  tostr(int n)        {stringstream rr;rr<<n;return rr.str();}
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int mod=1e9+7;
//ll qpow(ll n,ll k)          {ll ans=1;n%=mod;while(k){if(k&1) ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}
const int mxn=2e5+9;
const ld  eps=1e-9;
vll g[mxn];
ll col[mxn];
set<ll>se;
void dfs(ll u,ll c,ll dis)
{
    if(dis>2) c=1,dis=0;
    se.insert(c);
    col[u]=c;
    for(auto v:g[u]){
        if(!col[v]) dfs(v,c+1,dis+1),c++;
    }
}
int main()
{
    fast;
    ll i,j,k,n,m,mx=-1,u,v;
    cin>>n;
    for(i=0;i<n-1;i++){
        cin>>u>>v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(1,1,0);
    cout<<se.size()<<nl;
    for(i=1;i<=n;i++) cout<<col[i]<<' ';
    return 0;
}


#include<bits/stdc++.h>
#define LL long long int
#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define ss(a) scanf("%s",a)
#define w(t) while(t--)
#define f(i,n) for(i=0;i<n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define p(a) printf("%d",a)
#define pl(a) printf("%lld",a)
#define ps(a) printf("%s",a)
#define pc(a) printf("%c",a)
#define ent printf("\n")
#define mod 1000000007
#define PI 3.14159265
#define gs getline(cin,s)
#define pb push_back
#define mp make_pair
#define INF 1e18

using namespace std;

vector<int> v[200005];
int vis[200005];
int cnt[200005];
int no[200005];
int main()
{
    int n;
    cin>>n;
    int i;
    int x,y;
    fill(cnt,cnt+200005,0);
    fill(vis,vis+200005,0);
    f(i,n-1)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
        cnt[x]++;
        cnt[y]++;
    }
    int mx=2;
    for(i=1;i<=n;i++)
    {
        if(mx<=cnt[i])
        {
            mx=cnt[i];
          x=i;
        }
    }
    int t=mx+1;
    queue<int> q;
    vis[x]=0;
    q.push(x);
    int k=1;
    no[x]=1;
    while(!q.empty())
    {
        int ex1=q.front();
        q.pop();
        vis[ex1]=1;
     int p=0;
        for(i=0;i<v[ex1].size();i++)
        {
            int ex2=v[ex1][i];
            if(vis[ex2]==0)
            {
                vis[ex2]=1;
                q.push(ex2);
                no[ex2]=(no[ex1]%t+p%t+1%t)%(t);
                p++;
            }
        }
    }

    cout<<t<<endl;
    for(i=1;i<=n;i++)
    {
        if(no[i]>0)
            cout<<no[i]<<" ";
        else
            cout<<t<<" ";
    }
    ent;

    return 0;
}


#include<bits/stdc++.h>
#define LL long long int
#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define ss(a) scanf("%s",a)
#define w(t) while(t--)
#define f(i,n) for(i=0;i<n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define p(a) printf("%d",a)
#define pl(a) printf("%lld",a)
#define ps(a) printf("%s",a)
#define pc(a) printf("%c",a)
#define ent printf("\n")
#define mod 1000000007
#define PI 3.14159265
#define gs getline(cin,s)
#define pb push_back
#define mp make_pair
#define INF 1e18

using namespace std;

vector<int> v[200005];
int vis[200005];
int cnt[200005];
int no[200005];
int main()
{
    int n;
    cin>>n;
    int i;
    int x,y;
    fill(cnt,cnt+200005,0);
    fill(vis,vis+200005,0);
    f(i,n-1)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
        cnt[x]++;
        cnt[y]++;
    }
    int mx=2;
    for(i=1;i<=n;i++)
    {
        if(mx<=cnt[i])
        {
            mx=cnt[i];
          x=i;
        }
    }
    int t=mx+1;
    queue<int> q;
    vis[x]=0;
    q.push(x);
    int k=1;
    no[x]=1;
    while(!q.empty())
    {
        int ex1=q.front();
        q.pop();
        vis[ex1]=1;
     int p=0;
        for(i=0;i<v[ex1].size();i++)
        {
            int ex2=v[ex1][i];
            if(vis[ex2]==0)
            {

                vis[ex2]=1;
                q.push(ex2);
                no[ex2]=(no[ex1]+p+1)%(t);
                p++;
            }
        }
    }

    cout<<t<<endl;
    for(i=1;i<=n;i++)
    {
        if(no[i]>0)
            cout<<no[i]<<" ";
        else
            cout<<t<<" ";
    }
    ent;

    return 0;
}


#include<bits/stdc++.h>
#define LL long long int
#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define ss(a) scanf("%s",a)
#define w(t) while(t--)
#define f(i,n) for(i=0;i<n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define p(a) printf("%d",a)
#define pl(a) printf("%lld",a)
#define ps(a) printf("%s",a)
#define pc(a) printf("%c",a)
#define ent printf("\n")
#define mod 1000000007
#define PI 3.14159265
#define gs getline(cin,s)
#define pb push_back
#define mp make_pair
#define INF 1e18

using namespace std;

vector<int> v[200005];
int vis[200005];
int cnt[200005];
int no[200005];
int main()
{
    int n;
    cin>>n;
    int i;
    int x,y;
    fill(cnt,cnt+200005,0);
    fill(vis,vis+200005,0);
    f(i,n-1)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
        cnt[x]++;
        cnt[y]++;
    }
    int mx=2;
    for(i=1;i<=n;i++)
    {
        if(mx<=cnt[i])
        {
            mx=cnt[i];
          x=i;
        }
    }
    int t=mx+1;
    queue<int> q;
    vis[x]=0;
    q.push(x);
    int k=1;
    no[x]=1;
    while(!q.empty())
    {
        int ex1=q.front();
        q.pop();
        vis[ex1]=1;

        for(i=0;i<v[ex1].size();i++)
        {
            int ex2=v[ex1][i];
            if(vis[ex2]==0)
            {
                vis[ex2]=1;
                q.push(ex2);
                no[ex2]=(no[ex1]+i+1)%(t);
            }
        }
    }

    cout<<t<<endl;
    for(i=1;i<=n;i++)
    {
        if(no[i]>0)
            cout<<no[i]<<" ";
        else
            cout<<t<<" ";
    }
    ent;

    return 0;
}


#include<bits/stdc++.h>
#define LL long long int
#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define ss(a) scanf("%s",a)
#define w(t) while(t--)
#define f(i,n) for(i=0;i<n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define p(a) printf("%d",a)
#define pl(a) printf("%lld",a)
#define ps(a) printf("%s",a)
#define pc(a) printf("%c",a)
#define ent printf("\n")
#define mod 1000000007
#define PI 3.14159265
#define gs getline(cin,s)
#define pb push_back
#define mp make_pair
#define INF 1e18

using namespace std;

vector<int> v[200005];
int vis[200005];
int cnt[200005];
int no[200005];
int parent[200005];
int main()
{
    int n;
    cin>>n;
    int i;
    int x,y;
    fill(cnt,cnt+200005,0);
    fill(vis,vis+200005,0);
    f(i,n-1)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
        cnt[x]++;
        cnt[y]++;
    }
    int mx=2;
    for(i=1;i<=n;i++)
    {
        if(mx<=cnt[i])
        {
            mx=cnt[i];
          x=i;
        }
    }
    int t=mx+1;
    queue<int> q;
    vis[x]=0;
    q.push(x);
    int k=1;
    no[x]=1;
    while(!q.empty())
    {
        int ex1=q.front();
        q.pop();
        vis[ex1]=1;
     int p=0;
        for(i=0;i<v[ex1].size();i++)
        {
            int ex2=v[ex1][i];
            if(vis[ex2]==0)
            {
                parent[ex2]=ex1;
                vis[ex2]=1;
                q.push(ex2);
                if(ex1==x)
                {

                no[ex2]=(no[ex1]%t+p%t+1%t)%(t);

                p++;
                }
                else
                {
                    if(((no[ex1]+1+p)%t)!=no[parent[ex1]])
                no[ex2]=(no[ex1]%t+p%t+1%t)%(t);
                else
                    no[ex2]=(no[ex1]%t+p%t+2%t)%(t);
                p++;
                }
                }
        }
    }

    cout<<t<<endl;
    for(i=1;i<=n;i++)
    {
        if(no[i]>0)
            cout<<no[i]<<" ";
        else
            cout<<t<<" ";
    }
    ent;

    return 0;
}


#include<bits/stdc++.h>
#define LL long long int
#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define ss(a) scanf("%s",a)
#define w(t) while(t--)
#define f(i,n) for(i=0;i<n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define p(a) printf("%d",a)
#define pl(a) printf("%lld",a)
#define ps(a) printf("%s",a)
#define pc(a) printf("%c",a)
#define ent printf("\n")
#define mod 1000000007
#define PI 3.14159265
#define gs getline(cin,s)
#define pb push_back
#define mp make_pair
#define INF 1e18

using namespace std;

vector<int> v[200005];
int vis[200005];
int cnt[200005];
int no[200005];
int parent[200005];
int main()
{
    int n;
    cin>>n;
    int i;
    int x,y;
    fill(cnt,cnt+200005,0);
    fill(vis,vis+200005,0);
    f(i,n-1)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
        cnt[x]++;
        cnt[y]++;
    }
    int mx=2;
    for(i=1;i<=n;i++)
    {
        if(mx<=cnt[i])
        {
            mx=cnt[i];
          x=i;
        }
    }
    int t=mx+1;
    queue<int> q;
    vis[x]=0;
    q.push(x);
    int k=1;
    no[x]=1;
    while(!q.empty())
    {
        int ex1=q.front();
        q.pop();
        vis[ex1]=1;
     int p=0;
        for(i=0;i<v[ex1].size();i++)
        {
            int ex2=v[ex1][i];
            if(vis[ex2]==0)
            {
                parent[ex2]=ex1;
                vis[ex2]=1;
                q.push(ex2);
                if(ex1==x)
                {

                no[ex2]=(no[ex1]%t+p%t+1%t)%(t);

                p++;
                }
                else
                {
                    if(((no[ex1]%t+1%t+p%t)%t)!=no[parent[ex1]])
                    {
                no[ex2]=(no[ex1]%t+p%t+1%t)%(t);
                p++;
                    }
                else
                {
                    no[ex2]=(no[ex1]%t+p%t+2%t)%(t);
                p+=2;
                }
                }
             }
        }
    }

    cout<<t<<endl;
    for(i=1;i<=n;i++)
    {
        if(no[i]>0)
            cout<<no[i]<<" ";
        else
            cout<<t<<" ";
    }
    ent;

    return 0;
}


#include<bits/stdc++.h>
#define LL long long int
#define s(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define ss(a) scanf("%s",a)
#define w(t) while(t--)
#define f(i,n) for(i=0;i<n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define p(a) printf("%d",a)
#define pl(a) printf("%lld",a)
#define ps(a) printf("%s",a)
#define pc(a) printf("%c",a)
#define ent printf("\n")
#define mod 1000000007
#define PI 3.14159265
#define gs getline(cin,s)
#define pb push_back
#define mp make_pair
#define INF 1e18

using namespace std;

vector<int> v[200005];
int vis[200005];
int cnt[200005];
int no[200005];
int parent[200005];
int main()
{
    int n;
    cin>>n;
    int i;
    int x,y;
    fill(cnt,cnt+200005,0);
    fill(vis,vis+200005,0);
    f(i,n-1)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
        cnt[x]++;
        cnt[y]++;
    }
    int mx=2;
    for(i=1;i<=n;i++)
    {
        if(mx<=cnt[i])
        {
            mx=cnt[i];
          x=i;
        }
    }
    int t=mx+1;
    queue<int> q;
    vis[x]=0;
    q.push(x);
    int k=1;
    no[x]=1;
    while(!q.empty())
    {
        int ex1=q.front();
        q.pop();
        vis[ex1]=1;
     int p=0;
        for(i=0;i<v[ex1].size();i++)
        {
            int ex2=v[ex1][i];
            if(vis[ex2]==0)
            {
                parent[ex2]=ex1;
                vis[ex2]=1;
                q.push(ex2);
                if(ex1==x)
                {

                no[ex2]=(no[ex1]%t+p%t+1%t)%(t);

                p++;
                }
                else
                {
                    if(((no[ex1]%t+1%t+p%t)%t)!=no[parent[ex1]])
                no[ex2]=(no[ex1]%t+p%t+1%t)%(t);
                else
                    no[ex2]=(no[ex1]%t+p%t+2%t)%(t);
                p++;
                }
             }
        }
    }

    cout<<t<<endl;
    for(i=1;i<=n;i++)
    {
        if(no[i]>0)
            cout<<no[i]<<" ";
        else
            cout<<t<<" ";
    }
    ent;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = int(2e5) + 5;
vector<int> G[maxn];
int n;
int color[maxn];

void dfs(int u, int p) {
    int i = 1;
    for (auto v : G[u]) {
        if (color[v]) continue;
        while (color[u] == i or color[p] == i) i++;
        color[v] = i;
        dfs(v, u);
        i++;
    }
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v; u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }

    color[0] = 1;
    dfs(0, 0);

    int maxv = 0;
    for (int i = 0; i < n; i++) {
        maxv = max(color[i], maxv);
    }
    cout << maxv << endl;
    for (int i = 0; i < n; i++)
        cout << color[i] << " " ;
    cout << endl;
}