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

vector<int> l[200009];
set<int> s;
int vis[200009],cnt,val[200009];

void dfs(int ver){
	int i,j,t1,t2,temp;
	vis[ver]=1;
	s.clear();
	s.insert(val[ver]);
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		if(vis[t1]==1)
			s.insert(val[t1]);
	}
	temp=1;
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		if(vis[t1]==-1){
			while(s.find(temp)!=s.end())
				temp++;
			cnt=max(temp,cnt);
			val[t1]=temp;
			s.insert(temp);
			dfs(t1);
		}
	}
}

int main() {
	int i,j,t1,t2,t3,t4,ans,n;
	scanf("%d",&n);
	for(i=0;i<n-1;i++){
		scanf("%d %d",&t1,&t2);
		l[t1].push_back(t2);
		l[t2].push_back(t1);
	}
	memset(vis,-1,sizeof(vis));
	memset(val,-1,sizeof(val));
	cnt=1;
	val[1]=1;
	dfs(1);
	printf("%d\n",cnt);
	for(i=1;i<=n;i++){
		printf("%d ",val[i]);
	}
	printf("\n");
	return 0;
}


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

vector<int> l[100009];
set<int> s;
int vis[100009],val[100009],ans,cnt,don[100009];

void dfs(int ver){
	int i,j,t1,t2,c1,c2,c3,k;
	vis[ver]=1;
	if(val[ver]==-1){
		for(k=1;k<=cnt;k++){
			if(s.find(k)==s.end()){
				s.insert(k);
				val[ver]=k;
				break;
			}
		}
		if(val[ver]==-1){
			s.insert(++cnt);
			val[ver]=cnt;
		}
	}
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		//printf("y=%d\n",t1);
		if(vis[t1]==-1 && l[t1].size()>0){
			//printf("y=%d %d\n",t1,cnt);
			if(val[t1]==-1){
				for(k=1;k<=cnt;k++){
					if(s.find(k)==s.end()){
						s.insert(k);
						val[t1]=k;
						break;
					}
				}
				if(val[t1]==-1){
					s.insert(++cnt);
					val[t1]=cnt;
				}
			}
			for(j=0;j<l[t1].size();j++){
				t2=l[t1][j];
				if(val[t2]==-1){
					for(k=1;k<=cnt;k++){
						if(s.find(k)==s.end()){
							s.insert(k);
							val[t2]=k;
							break;
						}
					}
					if(val[t2]==-1){
						s.insert(++cnt);
						val[t2]=cnt;
					}
				}
			}
		}
		}
		s.erase(val[ver]);
		for(i=0;i<l[ver].size();i++){
			t1=l[ver][i];
			if(vis[t1]==-1 && l[t1].size()>0)
				dfs(t1);
		}
}

int main() {
	int i,j,t1,t2,t3,t4,x,y,n;
	scanf("%d",&n);
	for(i=0;i<n-1;i++){
		scanf("%d %d",&x,&y);
		l[x].push_back(y);
		l[y].push_back(x);
	}
	memset(vis,-1,sizeof(vis));
	memset(val,-1,sizeof(val));
	ans=0;
	cnt=1;
	s.clear();
	dfs(1);
	printf("%d\n",cnt);
	for(i=1;i<=n;i++){
		printf("%d ",val[i]);
	}
	printf("\n");
	return 0;
}


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

vector<int> l[100009];
set<int> s;
int vis[100009],cnt,val[100009];

void dfs(int ver){
	int i,j,t1,t2;
	vis[ver]=1;
	s.clear();
	s.insert(val[ver]);
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		if(vis[t1]==1)
			s.insert(val[t1]);
	}
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		if(vis[t1]==-1){
			for(j=1;j<=cnt;j++){
				if(s.find(j)==s.end()){
					val[t1]=j;
					s.insert(j);
					break;
				}
			}
			if(val[t1]==-1){
				val[t1]=++cnt;
				s.insert(val[t1]);
			}
			//dfs(t1);
		}
	}
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		if(vis[t1]==-1)
			dfs(t1);
	}
}

int main() {
	int i,j,t1,t2,t3,t4,ans,n;
	scanf("%d",&n);
	for(i=0;i<n-1;i++){
		scanf("%d %d",&t1,&t2);
		l[t1].push_back(t2);
		l[t2].push_back(t1);
	}
	memset(vis,-1,sizeof(vis));
	memset(val,-1,sizeof(val));
	cnt=1;
	val[1]=1;
	dfs(1);
	printf("%d\n",cnt);
	for(i=1;i<=n;i++){
		printf("%d ",val[i]);
	}
	printf("\n");
	return 0;
}


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

vector<int> l[100009];
set<int> s;
int vis[100009],val[100009],ans,cnt,don[100009];

void dfs(int ver){
	int i,j,t1,t2,c1,c2,c3,k;
	vis[ver]=1;
	if(val[ver]==-1){
		for(k=1;k<=cnt;k++){
			if(s.find(k)==s.end()){
				s.insert(k);
				val[ver]=k;
				break;
			}
		}
		if(val[ver]==-1){
			s.insert(++cnt);
			val[ver]=cnt;
		}
	}
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		//printf("y=%d\n",t1);
		if(vis[t1]==-1 && l[t1].size()>0){
			//printf("y=%d %d\n",t1,cnt);
			if(val[t1]==-1){
				for(k=1;k<=cnt;k++){
					if(s.find(k)==s.end()){
						s.insert(k);
						val[t1]=k;
						break;
					}
				}
				if(val[t1]==-1){
					s.insert(++cnt);
					val[t1]=cnt;
				}
			}
			for(j=0;j<l[t1].size();j++){
				t2=l[t1][j];
				if(val[t2]==-1){
					for(k=1;k<=cnt;k++){
						if(s.find(k)==s.end()){
							s.insert(k);
							val[t2]=k;
							break;
						}
					}
					if(val[t2]==-1){
						s.insert(++cnt);
						val[t2]=cnt;
					}
				}
			}
		}
		}
		//s.erase(val[ver]);
		for(i=0;i<l[ver].size();i++){
			t1=l[ver][i];
			if(vis[t1]==-1 && l[t1].size()>0)
				s.clear();
				s.insert(val[t1]);
				for(j=0;j<l[t1].size();j++){
					s.insert(val[l[t1][j]]);
				}
				dfs(t1);
		}
}

int main() {
	int i,j,t1,t2,t3,t4,x,y,n;
	scanf("%d",&n);
	for(i=0;i<n-1;i++){
		scanf("%d %d",&x,&y);
		l[x].push_back(y);
		l[y].push_back(x);
	}
	memset(vis,-1,sizeof(vis));
	memset(val,-1,sizeof(val));
	ans=0;
	cnt=1;
	s.clear();
	dfs(1);
	printf("%d\n",cnt);
	for(i=1;i<=n;i++){
		printf("%d ",val[i]);
	}
	printf("\n");
	return 0;
}


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

vector<int> l[100009];
set<int> s;
int vis[100009],cnt,val[100009];

void dfs(int ver){
	int i,j,t1,t2,temp;
	vis[ver]=1;
	s.clear();
	s.insert(val[ver]);
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		if(vis[t1]==1)
			s.insert(val[t1]);
	}
	temp=1;
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		if(vis[t1]==-1){
			while(s.find(temp)!=s.end())
				temp++;
			cnt=max(temp,cnt);
			val[t1]=temp;
			s.insert(temp);
			//dfs(t1);
		}
	}
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		if(vis[t1]==-1)
			dfs(t1);
	}
}

int main() {
	int i,j,t1,t2,t3,t4,ans,n;
	scanf("%d",&n);
	for(i=0;i<n-1;i++){
		scanf("%d %d",&t1,&t2);
		l[t1].push_back(t2);
		l[t2].push_back(t1);
	}
	memset(vis,-1,sizeof(vis));
	memset(val,-1,sizeof(val));
	cnt=1;
	val[1]=1;
	dfs(1);
	printf("%d\n",cnt);
	for(i=1;i<=n;i++){
		printf("%d ",val[i]);
	}
	printf("\n");
	return 0;
}


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

vector<int> l[200009];
set<int> s;
int vis[200009],cnt,val[200009];

void dfs(int ver){
	int i,j,t1,t2,temp;
	vis[ver]=1;
	s.clear();
	s.insert(val[ver]);
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		if(vis[t1]==1)
			s.insert(val[t1]);
	}
	temp=1;
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		if(vis[t1]==-1){
			while(s.find(temp)!=s.end())
				temp++;
			cnt=max(temp,cnt);
			val[t1]=temp;
			s.insert(temp);
			//dfs(t1);
		}
	}

	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		if(vis[t1]==-1)
			dfs(t1);
	}
}

int main() {
	int i,j,t1,t2,t3,t4,ans,n;
	scanf("%d",&n);
	for(i=0;i<n-1;i++){
		scanf("%d %d",&t1,&t2);
		l[t1].push_back(t2);
		l[t2].push_back(t1);
	}
	memset(vis,-1,sizeof(vis));
	memset(val,-1,sizeof(val));
	cnt=1;
	val[1]=1;
	dfs(1);
	printf("%d\n",cnt);
	for(i=1;i<=n;i++){
		printf("%d ",val[i]);
	}
	printf("\n");
	return 0;
}


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

vector<int> l[100009];
set<int> s;
int vis[100009],cnt,val[100009];

void dfs(int ver){
	int i,j,t1,t2;
	vis[ver]=1;
	s.clear();
	s.insert(val[ver]);
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		if(vis[t1]==1)
			s.insert(val[t1]);
	}
	for(i=0;i<l[ver].size();i++){
		t1=l[ver][i];
		if(vis[t1]==-1){
			for(j=1;j<=cnt;j++){
				if(s.find(j)==s.end()){
					val[t1]=j;
					s.insert(j);
					break;
				}
			}
			if(val[t1]==-1)
				val[t1]=++cnt;
			dfs(t1);
		}
	}
}

int main() {
	int i,j,t1,t2,t3,t4,ans,n;
	scanf("%d",&n);
	for(i=0;i<n-1;i++){
		scanf("%d %d",&t1,&t2);
		l[t1].push_back(t2);
		l[t2].push_back(t1);
	}
	memset(vis,-1,sizeof(vis));
	memset(val,-1,sizeof(val));
	cnt=1;
	val[1]=1;
	dfs(1);
	printf("%d\n",cnt);
	for(i=1;i<=n;i++){
		printf("%d ",val[i]);
	}
	printf("\n");
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;

vector <  vector< pair<int,int> > > adj(10001);
vector <int> d;
pair<int,int> v;
map<int,int> color;
map<int,int> parent;
int n,x,y,mx;

void bfs()
{

    d.clear();
    d.assign(n+1,0);
    color.clear();
    color[1]=1;
    mx=1;
    parent[1]=-1;
    queue<int> q;
    q.push(1);
    //cout<<1<<" "<<adj[1][0].first<<endl;
    //cout<<adj[2][0].first<<endl;
    while (!q.empty())
    {
        int u = q.front();
        int nb=1;
        d[u]=1;
        q.pop();
        for (int j = 0; j < (int)adj[u].size(); j++)
        {
            v = adj[u][j];
            //cout<<v.first<<" "<<u<<endl;

            if (d[v.first] == 0)
            {

               parent[v.first]=u;
            if(u==1)
            {
                if(nb==color[u])
                {
                    nb++;
                }
            }
            else
            {
                while(nb==color[parent[u]] || nb==color[u])
                {
                    nb++;
                }
            }
           // cout<<nb<<" "<<v.first<<endl;
            color[v.first]=nb;
            if(mx<nb){mx=nb;}
            nb++;

                d[v.first] = d[u] + 1;
                q.push(v.first);
            }
        }
    }

}

int main()
{

    cin >> n;
    for (int i=0; i<n-1; i++)
    {
        cin>>x>>y;
        adj[x].push_back(make_pair(y,0));
        adj[y].push_back(make_pair(x,0));

    }
    bfs();
    cout<<mx<<endl;
    for(int i=1; i<n; i++)
    {
        cout<<color[i]<<" ";
    }

    cout<<color[n]<<endl;

}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;

vector <  vector< pair<int,int> > > adj(10001);
vector <int> d;
pair<int,int> v;
map<int,int> color;
map<int,int> parent;
int n,x,y,mx;

void bfs()
{

    color[1]=1;
    mx=1;
    parent[1]=-1;
    queue<int> q;
    q.push(1);
    //cout<<1<<" "<<adj[1][0].first<<endl;
    //cout<<adj[2][0].first<<endl;
    while (!q.empty())
    {
        int u = q.front();
        int nb=1;
        d[u]=1;
        q.pop();
        for (int j = 0; j < (int)adj[u].size(); j++)
        {
            v = adj[u][j];
            //cout<<v.first<<" "<<u<<endl;

            if (d[v.first] == 0)
            {

               parent[v.first]=u;
            if(u==1)
            {
                if(nb==color[u])
                {
                    nb++;
                }
            }
            else
            {
                while(nb==color[parent[u]] || nb==color[u])
                {
                    nb++;
                }
            }
           // cout<<nb<<" "<<v.first<<endl;
            color[v.first]=nb;
            if(mx<nb){mx=nb;}
            nb++;

                d[v.first] = d[u] + 1;
                q.push(v.first);
            }
        }
    }

}

int main()
{

    cin >> n;
    for (int i=0; i<n-1; i++)
    {
        cin>>x>>y;
        adj[x].push_back(make_pair(y,0));
        adj[y].push_back(make_pair(x,0));

    }
    bfs();
    cout<<mx<<endl;
    for(int i=1; i<n; i++)
    {
        cout<<color[i]<<" ";
    }

    cout<<color[n]<<endl;

}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;

vector <  vector< pair<int,int> > > adj(10001);
vector <ll> d;
pair<ll,ll> v;
map<ll,ll> color;
map<ll,ll> parent;
ll n,x,y,mx;

void bfs()
{

    color[1]=1;
    mx=1;
    parent[1]=-1;
    queue<ll> q;
    q.push(1);
    //cout<<1<<" "<<adj[1][0].first<<endl;
    //cout<<adj[2][0].first<<endl;
    while (!q.empty())
    {
        int u = q.front();
        int nb=1;
        d[u]=1;
        q.pop();
        for (int j = 0; j < (int)adj[u].size(); j++)
        {
            v = adj[u][j];
            //cout<<v.first<<" "<<u<<endl;

            if (d[v.first] == 0)
            {

               parent[v.first]=u;
            if(u==1)
            {
                if(nb==color[u])
                {
                    nb++;
                }
            }
            else
            {
                while(nb==color[parent[u]] || nb==color[u])
                {
                    nb++;
                }
            }
           // cout<<nb<<" "<<v.first<<endl;
            color[v.first]=nb;
            if(mx<nb){mx=nb;}
            nb++;

                d[v.first] = d[u] + 1;
                q.push(v.first);
            }
        }
    }

}

int main()
{

    cin >> n;
    for (int i=0; i<n-1; i++)
    {
        cin>>x>>y;
        adj[x].push_back(make_pair(y,0));
        adj[y].push_back(make_pair(x,0));

    }
    bfs();
    cout<<mx<<endl;
    for(int i=1; i<n; i++)
    {
        cout<<color[i]<<" ";
    }

    cout<<color[n]<<endl;

}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;

vector <  vector< pair<int,int> > > adj(10001);
vector <int> d;
pair<int,int> v;
vector<int> color;
vector<int> parent;
int n,x,y,mx;

void bfs()
{

    d.clear();
    d.assign(n+1,0);
    color.clear();
        parent.clear();

color.assign(n+1,0);

parent.assign(n+1,0);

    color[1]=1;
    mx=1;
    parent[1]=-1;
    queue<int> q;
    q.push(1);
    //cout<<1<<" "<<adj[1][0].first<<endl;
    //cout<<adj[2][0].first<<endl;
    while (!q.empty())
    {
        int u = q.front();
        int nb=1;
        d[u]=1;
        q.pop();
        for (int j = 0; j < (int)adj[u].size(); j++)
        {
            v = adj[u][j];
            //cout<<v.first<<" "<<u<<endl;

            if (d[v.first] == 0)
            {

               parent[v.first]=u;
            if(u==1)
            {
                if(nb==color[u])
                {
                    nb++;
                }
            }
            else
            {
                while(nb==color[parent[u]] || nb==color[u])
                {
                    nb++;
                }
            }
           // cout<<nb<<" "<<v.first<<endl;
            color[v.first]=nb;
            if(mx<nb){mx=nb;}
            nb++;

                d[v.first] = d[u] + 1;
                q.push(v.first);
            }
        }
    }

}

int main()
{

    cin >> n;
    for (int i=0; i<n-1; i++)
    {
        cin>>x>>y;
        adj[x].push_back(make_pair(y,0));
        adj[y].push_back(make_pair(x,0));

    }
    bfs();
    cout<<mx<<endl;
    for(int i=1; i<n; i++)
    {
        cout<<color[i]<<" ";
    }

    cout<<color[n]<<endl;

}


#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;

vector <  vector< pair<int,int> > > adj(200100);
vector <int> d;
pair<int,int> v;
vector<int> color;
vector<int> parent;
int n,x,y,mx;

void bfs()
{

    d.clear();
    d.assign(n+1,0);
    color.clear();
    parent.clear();
    color.assign(n+1,0);
    parent.assign(n+1,0);
    color[1]=1;
    mx=1;
    parent[1]=-1;
    queue<int> q;
    q.push(1);
    //cout<<1<<" "<<adj[1][0].first<<endl;
    //cout<<adj[2][0].first<<endl;
    while (!q.empty())
    {
        int u = q.front();
        int nb=1;
        d[u]=1;
        q.pop();
        for (int j = 0; j < (int)adj[u].size(); j++)
        {
            v = adj[u][j];
            //cout<<v.first<<" "<<u<<endl;

            if (d[v.first] == 0)
            {

                parent[v.first]=u;
                if(u==1)
                {
                    if(nb==color[u])
                    {
                        nb++;
                    }
                }
                else
                {
                    while(nb==color[parent[u]] || nb==color[u])
                    {
                        nb++;
                    }
                }
                // cout<<nb<<" "<<v.first<<endl;
                color[v.first]=nb;
                if(mx<nb)
                {
                    mx=nb;
                }
                nb++;

                d[v.first] = d[u] + 1;
                q.push(v.first);
            }
        }
    }

}

int main()
{

    cin >> n;
    for (int i=0; i<n-1; i++)
    {
        cin>>x>>y;
        adj[x].push_back(make_pair(y,0));
        adj[y].push_back(make_pair(x,0));

    }
    bfs();
    cout<<mx<<endl;
    for(int i=1; i<n; i++)
    {
        cout<<color[i]<<" ";
    }

    cout<<color[n]<<endl;

}


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

typedef  long long ll;
ll n,k=0,f,h;
ll const N=200001;
vector<ll> v[N];

ll vm[N];
ll z[N];
ll z1[N];
ll vv[N];
ll father[N];

//vector<ll> v1[oo];
//ll z[oo];
pair<int, int> diameter(int i, int par = -1)
{
    int diam = 0;
    int mxHeights[3] = {-1, -1, -1};    // keep 2 highest trees

     for (ll j=0;j<v[i].size();j++) if(v[i][j] != par)
    {
        pair<int, int> p = diameter(v[i][j], i);
        diam = max(diam, p.first);

        // Keep only the 2 maximum children
        mxHeights[0] = p.second+1;
        sort(mxHeights, mxHeights+3);
    }

    for(ll h=0;h<3;h++) if(mxHeights[h] == -1)
        mxHeights[h] = 0;

    diam = max(diam, mxHeights[1] + mxHeights[2]);

    return make_pair(diam, mxHeights[2]);
}

void dfs(ll s)
{ //ll h=h1;
   if (z1[s]) return;
 z1[s] = 1;
 if(z[s]==-1) z[s]=vm[s]%3;
 bool test=false;
 for (ll u=0;u<v[s].size();u++)
     {if(z[v[s][u]]==-1) {z[v[s][u]]=(z[s]+vv[s]+1)%f;vv[s]++;} dfs(v[s][u]); }
 }

int main() {

ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll i,j,k,a=0,b=0,c=0,s=0;
memset(vv,0,sizeof(vv));
cin>>n;
for(i=0;i<n-1;i++)
{
   cin>>a>>b;
   v[a-1].push_back(b-1);
   v[b-1].push_back(a-1);

}
k=diameter(0,-1).first+1;
//cout<<k<<endl;
ll m=0;
//dfs(0);
for(i=0;i<n;i++)
{
    if(v[i].size()>m) {c=i;m=v[i].size();}

}
//if(c!=0) m--;
m++;
//cout<<m<<endl;
 s=3;
j=min(s,k);
//cout<<j<<endl;
f=max(j,m);
cout<<f<<endl;
	s = 0;

	map<ll, ll> len;
	queue<ll > q;

	//pts[s]=0;
	//pts[s1]=0;

	//if(x1==x2   && y1==y2) {cout<<0<<endl;pts.clear();continue;}
memset(z,-1,sizeof(z));
memset(father,-1,sizeof(father));

    q.push(s);len[s] = 0;vm[0]=0;//father[0]=-1;

	ll dep=0, sz=1;
	for (; !q.empty(); ++dep, sz=q.size()) {
		while (sz--) {
			ll c=q.front(); q.pop();
			if(z[c]==-1) z[c]=dep;

			for (i=0;i<v[c].size();i++) {

				                       ll p=v[c][i];

                                       if((len.count(p))) continue;

				//if (pts[p]==1 )
					//break;

				                       q.push(p), len[p]=dep+1;vm[p]=dep+1;
				                       father[p]=c;
				                       if(z[p]==-1) {z[p]=(z[c]+vv[c]+1)%f;if(z[p]==z[father[c]]) {z[p]++;z[p]%=f;}vv[c]++;}

			                              }
			}
		}

//for(i=0;i<n;i++)
//{if(z[i]==-1) {z[i]=vm[i]%3; }
//ll h=0;
    //for(j=0;j<v[i].size();j++)
    //{ if(z[v[i][j]]==-1) {z[v[i][j]]=(z[i]+h+1)%f;h++;}

   // }
//}
//cout<<f<<endl;
//dfs(0);
for(i=0;i<n;i++)
{
    cout<<z[i]+1<<" ";
  //cout<<vm[i]<<" "<<endl;
}

	return 0;
}


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

typedef  long long ll;
ll n,k=0,f,h;
ll const N=200001;
vector<ll> v[N];

ll vm[N];
ll z[N];
ll z1[N];
ll vv[N];

//vector<ll> v1[oo];
//ll z[oo];
pair<int, int> diameter(int i, int par = -1)
{
    int diam = 0;
    int mxHeights[3] = {-1, -1, -1};    // keep 2 highest trees

     for (ll j=0;j<v[i].size();j++) if(v[i][j] != par)
    {
        pair<int, int> p = diameter(v[i][j], i);
        diam = max(diam, p.first);

        // Keep only the 2 maximum children
        mxHeights[0] = p.second+1;
        sort(mxHeights, mxHeights+3);
    }

    for(ll h=0;h<3;h++) if(mxHeights[h] == -1)
        mxHeights[h] = 0;

    diam = max(diam, mxHeights[1] + mxHeights[2]);

    return make_pair(diam, mxHeights[2]);
}

void dfs(ll s)
{ //ll h=h1;
   if (z1[s]) return;
 z1[s] = 1;
 if(z[s]==-1) z[s]=vm[s]%3;
 bool test=false;
 for (ll u=0;u<v[s].size();u++)
     {if(z[v[s][u]]==-1) {z[v[s][u]]=(z[s]+vv[s]+1)%f;vv[s]++;} dfs(v[s][u]); }
 }

int main() {

ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll i,j,k,a=0,b=0,c=0,s=0;
memset(vv,0,sizeof(vv));
cin>>n;
for(i=0;i<n-1;i++)
{
   cin>>a>>b;
   v[a-1].push_back(b-1);
   v[b-1].push_back(a-1);

}
k=diameter(0,-1).first+1;
//cout<<k<<endl;
ll m=0;
//dfs(0);
for(i=0;i<n;i++)
{
    if(v[i].size()>m) {c=i;m=v[i].size();}

}
//if(c!=0) m--;
m++;
//cout<<m<<endl;
 s=3;
j=min(s,k);
//cout<<j<<endl;
f=max(j,m);
cout<<f<<endl;
	s = 0;

	map<ll, ll> len;
	queue<ll > q;

	//pts[s]=0;
	//pts[s1]=0;

	//if(x1==x2   && y1==y2) {cout<<0<<endl;pts.clear();continue;}

    q.push(s);len[s] = 0;vm[0]=0;

	ll dep=0, sz=1;
	for (; !q.empty(); ++dep, sz=q.size()) {
		while (sz--) {
			ll c=q.front(); q.pop();

			for (i=0;i<v[c].size();i++) {

				ll p=v[c][i];

                if((len.count(p))) continue;
				//if (pts[p]==1 )
					//break;

				q.push(p), len[p]=dep+1;vm[p]=dep+1;

			}
			}
		}

memset(z,-1,sizeof(z));
//for(i=0;i<n;i++)
//{if(z[i]==-1) {z[i]=vm[i]%3; }
//ll h=0;
    //for(j=0;j<v[i].size();j++)
    //{ if(z[v[i][j]]==-1) {z[v[i][j]]=(z[i]+h+1)%f;h++;}

   // }
//}
//cout<<f<<endl;
dfs(0);
for(i=0;i<n;i++)
{
    cout<<z[i]+1<<" ";
  //cout<<vm[i]<<" "<<endl;
}

	return 0;
}


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

typedef  long long ll;

ll n,m;

bool test=false,test1=false;

ll const N=2*1e5+7;

ll const oo=1000000007 ;

vector<ll> v,v1;

vector< pair<ll,ll>   > vv;

//ll  t[oo][oo];

//map<pair<ll,ll> ,ll> my1;

map<ll,ll> my,my1;

priority_queue<ll> q;

ll t[N];

//ll t1[N][N];
ll root(ll x) {
	ll l = 0, r = 1e9 + 1;
	while (l < r - 1) {
		ll m = (l + r) / 2;
		if (m * m > x)
			r = m;
		else
			l = m;
	}
	return l;
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};

bool verif(ll i,ll j)
{
    if(i>=0     && i<n  && j>=0   && j<m) return true;
    return false;
}

vector<ll> v2[N];
ll z[N];
ll col[N];
ll pr[N];
void dfs(ll s)
{
    if (z[s]) return;
 z[s] = 1;
 for (ll u=0;u<v2[s].size();u++)
    { if(z[v2[s][u]]!=1)  pr[v2[s][u]]=s; dfs(v2[s][u]); }
 }

 void dfscol(ll s)
{
    if (z[s]) return;
    //col[s]=col[pr[pr[s]]];
 z[s] = 1;
 //cout<<s<<endl;
 ll o=1;
 for (ll u=0;u<v2[s].size();u++)
    { if(col[v2[s][u]]==0) {while(o==col[s] || o==col[pr[s]]) o++; col[v2[s][u]]=o;o++;}  dfscol(v2[s][u]); }
 }

int main() {

ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll i=0,j=0,a=0,b=0,c=0,d=-1e18,x=0,y=0,s=0,r,l,k;
string s1,s2,s3,s4,s5;

cin>>n;
for(i=0;i<n-1;i++)
{
    cin>>a>>b;
    a--;
    b--;
    v2[a].push_back(b);
    v2[b].push_back(a);
}
for(i=0;i<n;i++)
{
    d=max(d,(ll)v2[i].size()+1);
}

cout<<d<<endl;
pr[0]=0;

col[0]=1;
for(i=0;i<v2[0].size();i++)
{
    col[v2[0][i]]=1+i+1;
}

dfs(0);
memset(z,0,sizeof z);
dfscol(0);

for(i=0;i<n;i++)
{    //cout<<pr[i]<<endl;
   cout<<col[i]<<" ";
}

   return 0;

}


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

typedef  long long ll;
ll n,k=0;;
ll const N=200001;
vector<ll> v[N];

ll vm[N];
ll z[N];

//vector<ll> v1[oo];
//ll z[oo];
pair<int, int> diameter(int i, int par = -1)
{
    int diam = 0;
    int mxHeights[3] = {-1, -1, -1};    // keep 2 highest trees

     for (ll j=0;j<v[i].size();j++) if(v[i][j] != par)
    {
        pair<int, int> p = diameter(v[i][j], i);
        diam = max(diam, p.first);

        // Keep only the 2 maximum children
        mxHeights[0] = p.second+1;
        sort(mxHeights, mxHeights+3);
    }

    for(ll h=0;h<3;h++) if(mxHeights[h] == -1)
        mxHeights[h] = 0;

    diam = max(diam, mxHeights[1] + mxHeights[2]);

    return make_pair(diam, mxHeights[2]);
}

//void dfs(ll s)
//{
   // if (z[s]) return;
 //z[s] = 1;
 //bool test=false;
 //for (ll u=0;u<v[s].size();u++)
    //{ dfs(v[s][u]); }
 //}

int main() {

ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

ll i,j,k,a=0,b=0,c=0,s=0;
cin>>n;
for(i=0;i<n-1;i++)
{
   cin>>a>>b;
   v[a-1].push_back(b-1);
   v[b-1].push_back(a-1);

}
k=diameter(0,-1).first+1;
//cout<<k<<endl;
ll m=0;
//dfs(0);
for(i=0;i<n;i++)
{
    if(v[i].size()>m) {c=i;m=v[i].size();}

}
//if(c!=0) m--;
m++;
//cout<<m<<endl;
 s=3;
j=min(s,k);
//cout<<j<<endl;
ll f=max(j,m);
cout<<f<<endl;
	s = 0;

	map<ll, ll> len;
	queue<ll > q;

	//pts[s]=0;
	//pts[s1]=0;

	//if(x1==x2   && y1==y2) {cout<<0<<endl;pts.clear();continue;}

    q.push(s);len[s] = 0;vm[0]=0;

	ll dep=0, sz=1;
	for (; !q.empty(); ++dep, sz=q.size()) {
		while (sz--) {
			ll c=q.front(); q.pop();

			for (i=0;i<v[c].size();i++) {

				ll p=v[c][i];

                if((len.count(p))) continue;
				//if (pts[p]==1 )
					//break;

				q.push(p), len[p]=dep+1;vm[p]=dep+1;

			}
			}
		}

memset(z,-1,sizeof(z));
for(i=0;i<n;i++)
{if(z[i]==-1) {z[i]=vm[i]%3; }
ll h=0;
    for(j=0;j<v[i].size();j++)
    { if(z[v[i][j]]==-1) {z[v[i][j]]=(z[i]+h+1)%f;h++;}

    }
}
//cout<<f<<endl;
for(i=0;i<n;i++)
{
    cout<<z[i]+1<<" ";
  //cout<<vm[i]<<" "<<endl;
}

	return 0;
}


#include <iostream>
#include<climits>
#include<vector>
#include<queue>
using namespace std;
int vis[200005];
int c[200005],par[200005];
long long int p=0;
vector<int> v[200005];
void dfs(int k)
{
    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int cur=q.front();
        c[cur]=p%k+1;
        ++p;
        vis[cur]=1;
        for(int i=0;i<v[cur].size();++i)
        {
            if(!vis[v[cur][i]])
            {
                q.push(v[cur][i]);
            }
        }
    }
}

int main()
{
    int n;
    cin>>n;

    int k=INT_MIN;
    for(int i=1;i<=n-1;++i)
    {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        k=max(k,max((int)v[a].size(),(int)v[b].size()));
        //cout<<k<<" "<<v[a].size()<<" "<<v[b].size()<<endl;
    }
    ++k;

    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int cur=q.front();
        q.pop();
        c[cur]=p%k+1;
        if(c[cur]==c[par[par[cur]]])
        {
            ++p;
            c[cur]=p%k+1;
        }
        ++p;
        vis[cur]=1;
        //cout<<cur<<" ";
        for(int i=0;i<v[cur].size();++i)
        {
            if(!vis[v[cur][i]])
            {
                q.push(v[cur][i]);
                par[v[cur][i]]=cur;
            }
        }
    }

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

}


#include <iostream>
#include<climits>
#include<vector>
#include<queue>
using namespace std;
int vis[200005];
int c[200005],par[200005];
long long int p=0;
vector<int> v[200005];
void dfs(int k)
{
    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int cur=q.front();
        c[cur]=p%k+1;
        ++p;
        vis[cur]=1;
        for(int i=0;i<v[cur].size();++i)
        {
            if(!vis[v[cur][i]])
            {
                q.push(v[cur][i]);
            }
        }
    }
}

int main()
{
    int n;
    cin>>n;

    int k=INT_MIN;
    for(int i=1;i<=n-1;++i)
    {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        k=max(k,max((int)v[a].size(),(int)v[b].size()));
        //cout<<k<<" "<<v[a].size()<<" "<<v[b].size()<<endl;
    }
    ++k;

    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int cur=q.front();
        q.pop();
        c[cur]=p%k+1;
        while(c[cur]==c[par[par[cur]]] || c[cur]==c[par[cur]])
        {
            ++p;
            c[cur]=p%k+1;
        }
        ++p;
        vis[cur]=1;
        //cout<<cur<<" ";
        for(int i=0;i<v[cur].size();++i)
        {
            if(!vis[v[cur][i]])
            {
                q.push(v[cur][i]);
                par[v[cur][i]]=cur;
            }
        }
    }

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

}


#include <iostream>
#include<climits>
#include<vector>
using namespace std;
int vis[200005];
int c[200005];
long long int p=0;
vector<int> v[200005];
void dfs(int s,int k,long long int p)
{
    if(!vis[s])
    {
        vis[s]=1;

        for(int i=0;i<v[s].size();++i)
        {
            int g=v[s][i];
            if(!vis[g])
            {
                dfs(g,k,p+v[s].size());
                c[g]=p%k+1;
                ++p;
            }
        }
    }
}

int main()
{
    int n;
    cin>>n;

    int k=INT_MIN;
    for(int i=1;i<=n-1;++i)
    {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        k=max(k,max((int)v[a].size(),(int)v[b].size()));
        //cout<<k<<" "<<v[a].size()<<" "<<v[b].size()<<endl;
    }
    ++k;
    dfs(1,k,1);
    c[1]=1;
    cout<<k<<endl;
    for(int i=1;i<=n;++i)
        cout<<c[i]<<" ";

}


#include <iostream>
#include<climits>
#include<vector>
#include<queue>
using namespace std;
int vis[200005];
int c[200005];
long long int p=0;
vector<int> v[200005];
void dfs(int k)
{
    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int cur=q.front();
        c[cur]=p%k+1;
        ++p;
        vis[cur]=1;
        for(int i=0;i<v[cur].size();++i)
        {
            if(!vis[v[cur][i]])
            {
                q.push(v[cur][i]);
            }
        }
    }
}

int main()
{
    int n;
    cin>>n;

    int k=INT_MIN;
    for(int i=1;i<=n-1;++i)
    {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        k=max(k,max((int)v[a].size(),(int)v[b].size()));
        //cout<<k<<" "<<v[a].size()<<" "<<v[b].size()<<endl;
    }
    ++k;

    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int cur=q.front();
        q.pop();
        c[cur]=p%k+1;
        ++p;
        vis[cur]=1;
        //cout<<cur<<" ";
        for(int i=0;i<v[cur].size();++i)
        {
            if(!vis[v[cur][i]])
            {
                q.push(v[cur][i]);
            }
        }
    }

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

}


#include <iostream>
#include<climits>
#include<vector>
using namespace std;
int vis[200005];
int c[200005],p=0;
vector<int> v[200005];
void dfs(int s,int k)
{
    if(!vis[s])
    {
        vis[s]=1;
        c[s]=p%k+1;
        ++p;
        for(int i=0;i<v[s].size();++i)
        {
            int g=v[s][i];
            if(!vis[g])
            {
                dfs(g,k);
                //c[g]=i%k+1;
            }
        }
    }
}

int main()
{
    int n;
    cin>>n;

    int k=INT_MIN;
    for(int i=1;i<=n-1;++i)
    {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        k=max(k,max((int)v[a].size(),(int)v[b].size()));
        //cout<<k<<" "<<v[a].size()<<" "<<v[b].size()<<endl;
    }
    ++k;
    dfs(1,k);
    //c[1]=k;
    cout<<k<<endl;
    for(int i=1;i<=n;++i)
        cout<<c[i]<<" ";

}


#include <iostream>
#include<climits>
#include<vector>
#include<queue>
using namespace std;
int vis[200005];
int c[200005],par[200005];
long long int p=0;
vector<int> v[200005];
void dfs(int k)
{
    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int cur=q.front();
        c[cur]=p%k+1;
        ++p;
        vis[cur]=1;
        for(int i=0;i<v[cur].size();++i)
        {
            if(!vis[v[cur][i]])
            {
                q.push(v[cur][i]);
            }
        }
    }
}

int main()
{
    int n;
    cin>>n;

    int k=INT_MIN;
    for(int i=1;i<=n-1;++i)
    {
        int a,b;
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
        k=max(k,max((int)v[a].size(),(int)v[b].size()));
        //cout<<k<<" "<<v[a].size()<<" "<<v[b].size()<<endl;
    }
    ++k;

    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int cur=q.front();
        q.pop();
        c[cur]=p%k+1;
        if(c[cur]==c[par[par[cur]]] || c[cur]==c[par[cur]])
        {
            ++p;
            c[cur]=p%k+1;
        }
        ++p;
        vis[cur]=1;
        //cout<<cur<<" ";
        for(int i=0;i<v[cur].size();++i)
        {
            if(!vis[v[cur][i]])
            {
                q.push(v[cur][i]);
                par[v[cur][i]]=cur;
            }
        }
    }

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

}


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

const int maxn = 2e5 + 10;
vector<int> G[maxn];
int c[maxn];

void dfs(int, int, vector<int>);

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int x, y; cin >> x >> y;
        G[x].push_back(y); G[y].push_back(x);
    }
    dfs(1, 0, vector<int>());
    int ans = 0;
    for (int i = 1; i <= n; ++i) ans = max(ans, c[i]);
    cout << ans << endl;
    for (int i = 1; i <= n; ++i) cout << c[i] << ' '; cout << endl;
    return 0;
}

void dfs(int x, int fa, vector<int> con) {
    bitset<maxn> used;
    used[c[fa]] = true;
    for (int i : con) used[c[i]] = true;
    int ind = 1; while (used[ind]) ++ind;
    c[x] = ind;
    vector<int> ch; ch.push_back(fa);
    for (int u : G[x]) if (u != fa) {
        dfs(u, x, ch);
        ch.push_back(u);
    }
}


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

const int maxn = 2e5 + 10;
vector<int> G[maxn];
int c[maxn];
bitset<maxn> used;

void dfs(int, int, vector<int>);

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int x, y; cin >> x >> y;
        G[x].push_back(y); G[y].push_back(x);
    }
    dfs(1, 0, vector<int>());
    int ans = 0;
    for (int i = 1; i <= n; ++i) ans = max(ans, c[i]);
    cout << ans << endl;
    for (int i = 1; i <= n; ++i) cout << c[i] << ' '; cout << endl;
    return 0;
}

void dfs(int x, int fa, vector<int> con) {
    // used.reset();
    used[c[fa]] = true;
    for (int i : con) used[c[i]] = true;
    int ind = 1; while (used[ind]) ++ind;
    used[c[fa]] = false;
    for (int i : con) used[c[i]] = true;
    c[x] = ind;
    vector<int> ch; ch.push_back(fa);
    for (int u : G[x]) if (u != fa) {
        dfs(u, x, ch);
        ch.push_back(u);
    }
}


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

inline int gtx() {
    const int N = 1048576;
    static char buffer[N];
    static char *p = buffer, *end = buffer;
    if (p == end) {
        if ((end = buffer + fread(buffer, 1, N, stdin)) == buffer) return EOF;
        p = buffer;
    }
    return *p++;
}

template <typename T>
inline bool rit(T& x) {
    char __c = 0; bool flag = false;
    while (__c = getchar(), (__c < '0' && __c != '-') || __c > '9') if (__c == -1) return false;
    __c == '-' ? (flag = true, x = 0) : (x = __c - '0');
    while (__c = getchar(), __c >= '0' && __c <= '9') x = x * 10 + __c - '0';
    if (flag) x = -x;
    return true;
}

template <typename T, typename ...Args>
inline bool rit(T& x, Args& ...args) { return rit(x) && rit(args...); }
const int maxn = 2e5 + 10;
vector<int> G[maxn];
int c[maxn];
bitset<maxn> used;

void dfs(int, int, vector<int>);

int main() {
    // ios_base::sync_with_stdio(false); cin.tie(0);
    int n; rit(n);
    for (int i = 0; i < n - 1; ++i) {
        int x, y; rit(x, y);
        G[x].push_back(y); G[y].push_back(x);
    }
    dfs(1, 0, vector<int>());
    int ans = 0;
    for (int i = 1; i <= n; ++i) ans = max(ans, c[i]);
    printf("%d\n", ans);
    for (int i = 1; i <= n; ++i) printf("%d ", c[i]); puts("");
    return 0;
}

void dfs(int x, int fa, vector<int> con) {
    used.reset();
    used[c[fa]] = true;
    for (int i : con) used[c[i]] = true;
    int ind = 1; while (used[ind]) ++ind;
    c[x] = ind;
    vector<int> ch; ch.push_back(fa);
    for (int u : G[x]) if (u != fa) {
        dfs(u, x, ch);
        ch.push_back(u);
    }
}


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

const int maxn = 2e5 + 10;
vector<int> G[maxn];
int c[maxn];
bitset<maxn> used;

void dfs(int, int, vector<int>);

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int x, y; cin >> x >> y;
        G[x].push_back(y); G[y].push_back(x);
    }
    dfs(1, 0, vector<int>());
    int ans = 0;
    for (int i = 1; i <= n; ++i) ans = max(ans, c[i]);
    cout << ans << endl;
    for (int i = 1; i <= n; ++i) cout << c[i] << ' '; cout << endl;
    return 0;
}

void dfs(int x, int fa, vector<int> con) {
    used.reset();
    used[c[fa]] = true;
    for (int i : con) used[c[i]] = true;
    int ind = 1; while (used[ind]) ++ind;
    c[x] = ind;
    vector<int> ch; ch.push_back(fa);
    for (int u : G[x]) if (u != fa) {
        dfs(u, x, ch);
        ch.push_back(u);
    }
}


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

const int maxn = 2e5 + 10;
vector<int> G[maxn];
int c[maxn];
bitset<maxn> used;

void dfs(int, int);

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int x, y; cin >> x >> y;
        G[x].push_back(y); G[y].push_back(x);
    }
    c[1] = 1; dfs(1, 0);
    int ans = 0;
    for (int i = 1; i <= n; ++i) ans = max(ans, c[i]);
    cout << ans << endl;
    for (int i = 1; i <= n; ++i) cout << c[i] << ' '; cout << endl;
    return 0;
}

void dfs(int x, int fa) {
    int ind = 1;
    for (int u : G[x]) if (u != fa) {
        while (ind == c[x] || ind == c[fa]) ++ind;
        c[u] = ind++;
        dfs(u, x);
    }
}


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

const int maxn = 2e5 + 10;
vector<int> G[maxn];
int c[maxn];
bitset<maxn> used;

void dfs(int, int, vector<int>);

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int x, y; cin >> x >> y;
        G[x].push_back(y); G[y].push_back(x);
    }
    dfs(1, 0, vector<int>());
    int ans = 0;
    for (int i = 1; i <= n; ++i) ans = max(ans, c[i]);
    cout << ans << endl;
    for (int i = 1; i <= n; ++i) cout << c[i] << ' '; cout << endl;
    return 0;
}

void dfs(int x, int fa, vector<int> con) {
    // used.reset();
    used[c[fa]] = true;
    for (int i : con) used[c[i]] = true;
    int ind = 1; while (used[ind]) ++ind;
    used[c[fa]] = false;
    for (int i : con) used[c[i]] = false;
    c[x] = ind;
    vector<int> ch; ch.push_back(fa);
    for (int u : G[x]) if (u != fa) {
        dfs(u, x, ch);
        ch.push_back(u);
    }
}


#include <bits/stdc++.h>
#define vi vector<int>
#define eps 1e-6
using namespace std;
const int maxn = 2e5 + 10;
vector<int> q[maxn];
int color[maxn];
int n;
bool vis[maxn];
map<int, int> hav[maxn];
set<int> cnt;
void dfs(int node, int fat)
{
    for(int i = 1; i <= n; i++)
        if(hav[fat][i] == 0)
        {
            color[node] = i;
            hav[fat][i] = 1;
            hav[node][i] = 1;
            break;
        }
    for(auto idx: q[node])
    {
        if(color[idx]) continue;
        hav[node][color[fat]] = 1;
        dfs(idx, node);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        q[a].push_back(b);
        q[b].push_back(a);
    }
    dfs(1, 1);
//    hav[1]1);
    for(int i = 1; i <= n; i++)
        cnt.insert(color[i]);
    cout << cnt.size() << endl;
    for(int i = 1; i <= n; i++)
        cout << color[i] << ' ';
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define eps 1e-6
using namespace std;
const int maxn = 2e5 + 10;
struct edge{
    int to, nxt;
};
edge q[2 * maxn];
int color[maxn];
int tot = 1;
bool vis[maxn];
int head[maxn];
int n;
void dfs(int node, int fat, int c1, int c2)
{
    int idx = 1;
    for(int i = head[node]; i; i = q[i].nxt)
    {
        edge e = q[i];
        if(e.to == fat) continue;
        for(;idx <= n; idx++)
            if(idx != c1 && idx != c2)
            {
                color[e.to] = idx++;
                break;
            }
        dfs(e.to, node, color[node], color[e.to]);

    }
}
void add(int a, int b)
{
    q[tot] = edge{b, head[a]};
    head[a] = tot++;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        add(a, b);
        add(b, a);
    }
    color[1] = 1;
    dfs(1, -1, 1, -1);
    set<int> count;
    for(int i = 1; i <= n; i++)
        count.insert(color[i]);
    cout << count.size() << endl;
    for(int i = 1; i <= n; i++)
        cout << color[i] << ' ';
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define eps 1e-6
using namespace std;
const int maxn = 2e5 + 10;
vector<int> q[maxn];
int color[maxn];
int n;
bool vis[maxn];void dfs(int node, int fat, int c1, int c2)
{
    int index = 1;
    for(int i = 0; i < q[node].size(); i++)
    {
        int idx = q[node][i];
        if(idx == fat) continue;
        for(; index <= n; index++)
            if(index != c1 && index != c2)
            {
                color[idx] = index++;
                break;
            }
        dfs(idx, node, color[idx], color[node]);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        q[a].push_back(b);
        q[b].push_back(a);
    }
    color[1] = 1;
    dfs(1, -1, 1, -1);
    int num = 0;
    for(int i = 1; i <= n; i++)
        num = max(num, (int)q[i].size() + 1);
    cout << num << endl;
    for(int i = 1; i <= n; i++)
        cout << color[i] << ' ';
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define eps 1e-6
using namespace std;
const int maxn = 2e2 + 10;
vector<int> q[maxn];
int color[maxn];
int n;
bool vis[maxn];
map<int, int> hav[maxn];
set<int> cnt;
void dfs(int node, int fat)
{
    for(int i = 1; i <= n; i++)
        if(hav[fat][i] == 0)
        {
            color[node] = i;
            hav[fat][i] = 1;
            hav[node][i] = 1;
            break;
        }
    for(auto idx: q[node])
    {
        if(color[idx]) continue;
        hav[node][color[fat]] = 1;
        dfs(idx, node);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        q[a].push_back(b);
        q[b].push_back(a);
    }
    dfs(1, 1);
//    hav[1]1);
    for(int i = 1; i <= n; i++)
        cnt.insert(color[i]);
    cout << cnt.size() << endl;
    for(int i = 1; i <= n; i++)
        cout << color[i] << ' ';
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define eps 1e-6
using namespace std;
const int maxn = 2e5 + 10;
vector<int> q[maxn];
int color[maxn];
int n;
bool vis[maxn];
set<int> hav[maxn];
set<int> cnt;
void dfs(int node, int fat)
{
    for(int i = 1; i <= n; i++)
        if(hav[fat].find(i) == hav[fat].end())
        {
            color[node] = i;
            hav[fat].insert(i);
            hav[node].insert(i);
            break;
        }
    for(auto idx: q[node])
    {
        if(color[idx]) continue;
        hav[node].insert(color[fat]);
        dfs(idx, node);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        q[a].push_back(b);
        q[b].push_back(a);
    }
    dfs(1, 1);
    hav[1].insert(1);
    for(int i = 1; i <= n; i++)
        cnt.insert(color[i]);
    cout << cnt.size() << endl;
    for(int i = 1; i <= n; i++)
        cout << color[i] << ' ';
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define eps 1e-6
using namespace std;
const int maxn = 1e5 + 10;
vector<int> q[maxn];
int color[maxn];
int n;
bool vis[maxn];
bool col[maxn];
void dfs(int node, int depth)
{
    if(depth == 1) vis[node] = 1;
    if(color[node] == 0)
        for(int i = 1; i <= n; i++)
            if(col[i] == 0)
            {
                color[node] = i;
                col[i] = 1;
                break;
            }
    if(depth == 3) return;
    for(auto idx: q[node])
    {
        if(vis[idx]) continue;
        dfs(idx, depth + 1);
    }
    if(depth == 1)
    {
        col[color[node]] = 0;
        for(auto idx: q[node])
            if(vis[idx] == 0)
            dfs(idx, 1);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        q[a].push_back(b);
        q[b].push_back(a);
    }
    color[1] = 1;
    col[1] = 1;
    dfs(1, 1);
    for(int i = 1; i <= n; i++)
        cout << color[i] << ' ';
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define eps 1e-6
using namespace std;
const int maxn = 2e2 + 10;
vector<int> q[maxn];
int color[maxn];
int n;
bool vis[maxn];
set<int> hav[maxn];
set<int> cnt;
void dfs(int node, int fat)
{
    for(int i = 1; i <= n; i++)
        if(hav[fat].find(i) == hav[fat].end())
        {
            color[node] = i;
            hav[fat].insert(i);
            hav[node].insert(i);
            break;
        }
    for(auto idx: q[node])
    {
        if(color[idx]) continue;
        hav[node].insert(color[fat]);
        dfs(idx, node);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        q[a].push_back(b);
        q[b].push_back(a);
    }
    dfs(1, 1);
    hav[1].insert(1);
    for(int i = 1; i <= n; i++)
        cnt.insert(color[i]);
    cout << cnt.size() << endl;
    for(int i = 1; i <= n; i++)
        cout << color[i] << ' ';
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define eps 1e-6
using namespace std;
const int maxn = 2e5 + 10;
vector<int> q[maxn];
int color[maxn];
int n;
bool vis[maxn];
bool col[maxn];
set<int> cnt;
void dfs(int node, int depth)
{
    if(depth == 1) vis[node] = 1;
    if(color[node] == 0)
        for(int i = 1; i <= n; i++)
            if(col[i] == 0)
            {
                color[node] = i;
                col[i] = 1;
                break;
            }
    if(depth == 2) return;
    for(auto idx: q[node])
    {
        if(vis[idx]) continue;
        dfs(idx, depth + 1);
    }
    if(depth == 1)
    {
        col[color[node]] = 0;
        for(auto idx: q[node])
            if(vis[idx] == 0)
            dfs(idx, 1);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        q[a].push_back(b);
        q[b].push_back(a);
    }
    color[1] = 1;
    col[1] = 1;
    dfs(1, 1);
    for(int i = 1; i <= n; i++)
        cnt.insert(color[i]);
    cout << cnt.size() << endl;
    for(int i = 1; i <= n; i++)
        cout << color[i] << ' ';
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define eps 1e-6
using namespace std;
const int maxn = 2e5 + 10;
vector<int> q[maxn];
int color[maxn];
int n;
bool vis[maxn];
map<int, int> hav[maxn];
void dfs(int node, int fat, int c1, int c2)
{
    int index = 1;
    for(int i = 0; i < q[node].size(); i++)
    {
        int idx = q[node][i];
        if(idx == fat) continue;
        for(; index <= n; index++)
            if(index != c1 && index != c2)
            {
                color[idx] = index++;
                break;
            }
        dfs(idx, node, color[idx], color[node]);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        q[a].push_back(b);
        q[b].push_back(a);
    }
    color[1] = 1;
    dfs(1, -1, 1, -1);
    int num = 0;
    for(int i = 1; i <= n; i++)
        num = max(num, (int)q[i].size() + 1);
    cout << num << endl;
    for(int i = 1; i <= n; i++)
        cout << color[i] << ' ';
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define eps 1e-6
using namespace std;
const int maxn = 2e5 + 10;
vector<int> q[maxn];
int color[maxn];
int n;
bool vis[maxn];
bool col[maxn];
set<int> cnt;
void dfs(int node, int depth)
{
    if(depth == 1) vis[node] = 1;
    if(color[node] == 0)
        for(int i = 1; i <= n; i++)
            if(col[i] == 0)
            {
                color[node] = i;
                col[i] = 1;
                break;
            }
    if(depth == 3) return;
    for(auto idx: q[node])
    {
        if(vis[idx]) continue;
        dfs(idx, depth + 1);
    }
    if(depth == 1)
    {
        col[color[node]] = 0;
        for(auto idx: q[node])
            if(vis[idx] == 0)
            dfs(idx, 1);
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        q[a].push_back(b);
        q[b].push_back(a);
    }
    color[1] = 1;
    col[1] = 1;
    dfs(1, 1);
    for(int i = 1; i <= n; i++)
        cnt.insert(color[i]);
    cout << cnt.size() << endl;
    for(int i = 1; i <= n; i++)
        cout << color[i] << ' ';
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
#define vi vector<int>
#define eps 1e-6
using namespace std;
const int maxn = 2e2 + 10;
struct edge{
    int to, nxt;
};
edge q[2 * maxn];
int color[maxn];
int tot = 1;
bool vis[maxn];
int head[maxn];
int n;
void dfs(int node, int fat, int c1, int c2)
{
    int idx = 1;
    for(int i = head[node]; i; i = q[i].nxt)
    {
        edge e = q[i];
        if(e.to == fat) continue;
        for(;idx <= n; idx++)
            if(idx != c1 && idx != c2)
            {
                color[e.to] = idx++;
                break;
            }
        dfs(e.to, node, color[node], color[e.to]);

    }
}
void add(int a, int b)
{
    q[tot] = edge{b, head[a]};
    head[a] = tot++;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        add(a, b);
        add(b, a);
    }
    color[1] = 1;
    dfs(1, -1, 1, -1);
    set<int> count;
    for(int i = 1; i <= n; i++)
        count.insert(color[i]);
    cout << count.size() << endl;
    for(int i = 1; i <= n; i++)
        cout << color[i] << ' ';
    cout << endl;
    return 0;
}


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

ifstream fin("input.txt");
ofstream fout("output.txt");

bool isPrime(long long int x) { if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
    for (int i = 5; i * i <= x; i += 6) if (x % i == 0 || x % (i + 2) == 0) return 0; return 1; }

void primeFactors(long long n, set<long long> &Fac) {
    // Print the number of 2s that divide n
    while (n%2 == 0)
    {
        Fac.insert(2);
        n = n/2;
    }

    // n must be odd at this point.  So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        // While i divides n, print i and divide n
        while (n%i == 0)
        {
            Fac.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        Fac.insert(n);
}
int NumDigits(int x)
{
    //x = abs(x);
    return (x < 10 ? 1 :
        (x < 100 ? 2 :
        (x < 1000 ? 3 :
        (x < 10000 ? 4 :
        (x < 100000 ? 5 :
        (x < 1000000 ? 6 :
        (x < 10000000 ? 7 :
        (x < 100000000 ? 8 :
        (x < 1000000000 ? 9 :
        10)))))))));
}

inline void boostIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    cout.precision(10);
}

typedef long long int ll;
typedef long double ld;

#define fori(n)  for(int i = 0; i < (n); ++i)
#define forj(n)  for(int j = 0; j < (n); ++j)
#define fork(n) for(int k = 0; k < (n); ++k)
#define forx(n) for(int x = 0; x < (n); ++x)

#define LONG_LONG_MAX  9223372036854775807
#define LONG_LONG_MIN   -9223372036854775807
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))

#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " " << x.ff << " " << x.ss << endl;
#define debug_v(x) cerr << #x << " "; for (auto ii : x) cout << ii << " "; cout << endl;
#define debug_vp(x) cerr << #x << " "; for (auto ii : x) cout << '[' << ii.ff << " " << ii.ss << ']'; cout << endl;
#define mp make_pair

#define Return cerr<<endl<<"RUNTIME: "<<1.0*clock()/CLOCKS_PER_SEC << " s" <<endl; return 0;

#define PI 3.14159265

ll Pow10[19] = {(ll)0,(ll)1e1,(ll)1e2,(ll)1e3,(ll)1e4,(ll)1e5,(ll)1e6,(ll)1e7,(ll)1e8,(ll)1e9,(ll)1e10,
                (ll)1e11,(ll)1e12,(ll)1e13,(ll)1e14,(ll)1e15,(ll)1e16,(ll)1e17,(ll)1e18};
//be careful with pow(), cuz it returns NOT AN INTEGER

//int mid = low + ((high - low) / 2);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b);}

struct Mine {
    int g = 0;
    int x = 0;
    int y = 0;
    int X = 0;
    int Y = 0;
};
/*
struct comp {
    bool operator()(Mine const & a, Mine const & b) {
        return a.g >= b.g;
    }
};
set<Mine, comp> Set;
*/

//__builtin_clz(int); amount of 0 in the begining
//__builtin_ctz(int); amoint of 0 in the end
//__builtin_popcount(int); amount of 1

//memset(dp, -1, sizeof dp);

/////////////////////
#define int long long
int MOD = 1e9 + 7;
#define endl '\n'
////////////////////

template <class T> struct Fenwick {
    vector<T> V;
    Fenwick(int n): V(n) {}
    void add(size_t i, T x) { for (; i < V.size(); i |= i + 1) V[i] += x; }
    T sum(int i) { T r = T(); for (--i; i >= 0; i = (i & (i + 1)) - 1) r += V[i]; return r; }
    T sum(int l, int r) { return sum(r) - sum(l); }
};

//Cartesian tree (Treap)

////////////////////////////////////////////////////////////////////
/////////Segment tree///////////////////////////////////////////////
int f_Minimum(int a, int b) {
    return(min(a, b));
}
int f_Maximum(int a, int b) {
    return(max(a, b));
}
int f_Summarize (int a, int b) {
    return(a + b);
}

class Parameter {
    public:
        int InitialValue;
        int (*Function)(int a, int b);

        Parameter(int (*f)(int a, int b), int value) {
            Function = f;
            InitialValue = value;
        }
    private:
};

Parameter Minimum(f_Minimum, LONG_LONG_MAX);
Parameter Maximum(f_Maximum, LONG_LONG_MIN);
Parameter Summarize(f_Summarize, 0);

class SegmentTree {
    public:
        SegmentTree(int size, Parameter p) {
            Function = p.Function;
            InitialValue = p.InitialValue;
            n = size;
            data = vector<int>(2*n, 0);
        }
        SegmentTree(vector<int> array, Parameter p) {
            Function = p.Function;
            InitialValue = p.InitialValue;
            n = array.size();;
            data = vector<int>(2*n, 0);
            fori(n) {
                data[n + i] = array[i];
            }
            for (int i = n-1; i >= 1; ++i) {
                data[i] = Function(data[i*2], data[i*2]+1);
            }
        }

        void Update(int idx, int value) {
            idx += n;
            data[idx] = value;

            while(idx > 1) {
                idx /= 2;
                data[idx] = Function(data[idx*2], data[idx*2+1]);
            }
        }
        int Find(int left, int right) { // [left; right)
            left += n;
            right += n;

            int value = InitialValue;
            while (left < right) {
                if (left % 2 == 1) {
                    value = Function(left, value);
                    left++;
                }
                if (right % 2 == 1) {
                    value = Function(right, value);
                    right--;
                }
                left /= 2; right /= 2;
            }
            return value;
        }

    private:
        int n;
        vector<int> data;
        int (*Function)(int a, int b);
        int InitialValue;
};
/////////Segment tree///////////////////////////////////////////////
////////////////////////////////////////////////////////////////////

int32_t main() {
    boostIO();
    int n; cin >> n;
    vector<vector<int>> adj(n, vector<int> (0));
    fori(n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    vector<vector<int>> A(n, vector<int> (n, 0));
    vector<int> Colour(n);
    queue<int> Q;
    int max_k = 0;
    Colour[0] = 1;
    A[0][1] = 1;
    Q.push(0);
    while(Q.size() > 0) {
        int node = Q.front();
        Q.pop();
        for(auto x : adj[node]) {
            if (Colour[x] == 0) {
                int k = 1;
                while(A[node][k] == 1) {
                    ++k;
                    max_k = max(max_k, k);
                }
                Colour[x] = k;
                A[x][k] = 1;
                Q.push(x);
                A[node][k] = 1;
                A[x][Colour[node]]=1;
            }
        }
    }
    cout << max_k << endl;
    fori(n) {
        cout << Colour[i] << " ";
    }

    Return;
}


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

ifstream fin("input.txt");
ofstream fout("output.txt");

bool isPrime(long long int x) { if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
    for (int i = 5; i * i <= x; i += 6) if (x % i == 0 || x % (i + 2) == 0) return 0; return 1; }

void primeFactors(long long n, set<long long> &Fac) {
    // Print the number of 2s that divide n
    while (n%2 == 0)
    {
        Fac.insert(2);
        n = n/2;
    }

    // n must be odd at this point.  So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        // While i divides n, print i and divide n
        while (n%i == 0)
        {
            Fac.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        Fac.insert(n);
}
int NumDigits(int x)
{
    //x = abs(x);
    return (x < 10 ? 1 :
        (x < 100 ? 2 :
        (x < 1000 ? 3 :
        (x < 10000 ? 4 :
        (x < 100000 ? 5 :
        (x < 1000000 ? 6 :
        (x < 10000000 ? 7 :
        (x < 100000000 ? 8 :
        (x < 1000000000 ? 9 :
        10)))))))));
}

inline void boostIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    cout.precision(10);
}

typedef long long int ll;
typedef long double ld;

#define fori(n)  for(int i = 0; i < (n); ++i)
#define forj(n)  for(int j = 0; j < (n); ++j)
#define fork(n) for(int k = 0; k < (n); ++k)
#define forx(n) for(int x = 0; x < (n); ++x)

#define LONG_LONG_MAX  9223372036854775807
#define LONG_LONG_MIN   -9223372036854775807
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))

#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " " << x.ff << " " << x.ss << endl;
#define debug_v(x) cerr << #x << " "; for (auto ii : x) cout << ii << " "; cout << endl;
#define debug_vp(x) cerr << #x << " "; for (auto ii : x) cout << '[' << ii.ff << " " << ii.ss << ']'; cout << endl;
#define mp make_pair

#define Return cerr<<endl<<"RUNTIME: "<<1.0*clock()/CLOCKS_PER_SEC << " s" <<endl; return 0;

#define PI 3.14159265

ll Pow10[19] = {(ll)0,(ll)1e1,(ll)1e2,(ll)1e3,(ll)1e4,(ll)1e5,(ll)1e6,(ll)1e7,(ll)1e8,(ll)1e9,(ll)1e10,
                (ll)1e11,(ll)1e12,(ll)1e13,(ll)1e14,(ll)1e15,(ll)1e16,(ll)1e17,(ll)1e18};
//be careful with pow(), cuz it returns NOT AN INTEGER

//int mid = low + ((high - low) / 2);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b);}

 /*
struct Mine {
    int g = 0;
    int x = 0;
    int y = 0;
    int X = 0;
    int Y = 0;
};
/
struct comp {
    bool operator()(Mine const & a, Mine const & b) {
        return a.g >= b.g;
    }
};
set<Mine, comp> Set;
*/

//__builtin_clz(int); amount of 0 in the begining
//__builtin_ctz(int); amoint of 0 in the end
//__builtin_popcount(int); amount of 1

//memset(dp, -1, sizeof dp);

/////////////////////
#define int long long
int MOD = 1e9 + 7;
#define endl '\n'
////////////////////

template <class T> struct Fenwick {
    vector<T> V;
    Fenwick(int n): V(n) {}
    void add(size_t i, T x) { for (; i < V.size(); i |= i + 1) V[i] += x; }
    T sum(int i) { T r = T(); for (--i; i >= 0; i = (i & (i + 1)) - 1) r += V[i]; return r; }
    T sum(int l, int r) { return sum(r) - sum(l); }
};

//Cartesian tree (Treap)

////////////////////////////////////////////////////////////////////
/////////Segment tree///////////////////////////////////////////////
int f_Minimum(int a, int b) {
    return(min(a, b));
}
int f_Maximum(int a, int b) {
    return(max(a, b));
}
int f_Summarize (int a, int b) {
    return(a + b);
}

class Parameter {
    public:
        int InitialValue;
        int (*Function)(int a, int b);

        Parameter(int (*f)(int a, int b), int value) {
            Function = f;
            InitialValue = value;
        }
    private:
};

Parameter Minimum(f_Minimum, LONG_LONG_MAX);
Parameter Maximum(f_Maximum, LONG_LONG_MIN);
Parameter Summarize(f_Summarize, 0);

class SegmentTree {
    public:
        SegmentTree(int size, Parameter p) {
            Function = p.Function;
            InitialValue = p.InitialValue;
            n = size;
            data = vector<int>(2*n, 0);
        }
        SegmentTree(vector<int> array, Parameter p) {
            Function = p.Function;
            InitialValue = p.InitialValue;
            n = array.size();;
            data = vector<int>(2*n, 0);
            fori(n) {
                data[n + i] = array[i];
            }
            for (int i = n-1; i >= 1; ++i) {
                data[i] = Function(data[i*2], data[i*2]+1);
            }
        }

        void Update(int idx, int value) {
            idx += n;
            data[idx] = value;

            while(idx > 1) {
                idx /= 2;
                data[idx] = Function(data[idx*2], data[idx*2+1]);
            }
        }
        int Find(int left, int right) { // [left; right)
            left += n;
            right += n;

            int value = InitialValue;
            while (left < right) {
                if (left % 2 == 1) {
                    value = Function(left, value);
                    left++;
                }
                if (right % 2 == 1) {
                    value = Function(right, value);
                    right--;
                }
                left /= 2; right /= 2;
            }
            return value;
        }

    private:
        int n;
        vector<int> data;
        int (*Function)(int a, int b);
        int InitialValue;
};
/////////Segment tree///////////////////////////////////////////////
////////////////////////////////////////////////////////////////////

int32_t main() {
    boostIO();
    int n; cin >> n;
    vector<vector<int>> adj(n, vector<int> (0));
    fori(n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    vector<unordered_set<int>> A(n);
    vector<int> Colour(n);
    queue<int> Q;
    int max_k = 0;
    Colour[0] = 1;
    A[0].insert(1);
    Q.push(0);
    while(Q.size() > 0) {
        int node = Q.front();
        Q.pop();
        int k = 1;
        for(auto x : adj[node]) {
            if (Colour[x] == 0) {
                while(A[node].find(k) != A[node].end()) {
                    ++k;
                    max_k = max(max_k, k);
                }
                Colour[x] = k;
                A[x].insert(k);
                Q.push(x);
                A[node].insert(k);
                A[x].insert(Colour[node]);
            }
        }
    }
    cout << max_k << endl;
    fori(n) {
        cout << Colour[i] << " ";
    }

    Return;
}


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

ifstream fin("input.txt");
ofstream fout("output.txt");

bool isPrime(long long int x) { if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
    for (int i = 5; i * i <= x; i += 6) if (x % i == 0 || x % (i + 2) == 0) return 0; return 1; }

void primeFactors(long long n, set<long long> &Fac) {
    // Print the number of 2s that divide n
    while (n%2 == 0)
    {
        Fac.insert(2);
        n = n/2;
    }

    // n must be odd at this point.  So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        // While i divides n, print i and divide n
        while (n%i == 0)
        {
            Fac.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        Fac.insert(n);
}
int NumDigits(int x)
{
    //x = abs(x);
    return (x < 10 ? 1 :
        (x < 100 ? 2 :
        (x < 1000 ? 3 :
        (x < 10000 ? 4 :
        (x < 100000 ? 5 :
        (x < 1000000 ? 6 :
        (x < 10000000 ? 7 :
        (x < 100000000 ? 8 :
        (x < 1000000000 ? 9 :
        10)))))))));
}

inline void boostIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    cout.precision(10);
}

typedef long long int ll;
typedef long double ld;

#define fori(n)  for(int i = 0; i < (n); ++i)
#define forj(n)  for(int j = 0; j < (n); ++j)
#define fork(n) for(int k = 0; k < (n); ++k)
#define forx(n) for(int x = 0; x < (n); ++x)

#define LONG_LONG_MAX  9223372036854775807
#define LONG_LONG_MIN   -9223372036854775807
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))

#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " " << x.ff << " " << x.ss << endl;
#define debug_v(x) cerr << #x << " "; for (auto ii : x) cout << ii << " "; cout << endl;
#define debug_vp(x) cerr << #x << " "; for (auto ii : x) cout << '[' << ii.ff << " " << ii.ss << ']'; cout << endl;
#define mp make_pair

#define Return cerr<<endl<<"RUNTIME: "<<1.0*clock()/CLOCKS_PER_SEC << " s" <<endl; return 0;

#define PI 3.14159265

ll Pow10[19] = {(ll)0,(ll)1e1,(ll)1e2,(ll)1e3,(ll)1e4,(ll)1e5,(ll)1e6,(ll)1e7,(ll)1e8,(ll)1e9,(ll)1e10,
                (ll)1e11,(ll)1e12,(ll)1e13,(ll)1e14,(ll)1e15,(ll)1e16,(ll)1e17,(ll)1e18};
//be careful with pow(), cuz it returns NOT AN INTEGER

//int mid = low + ((high - low) / 2);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b);}

struct Mine {
    int g = 0;
    int x = 0;
    int y = 0;
    int X = 0;
    int Y = 0;
};
/*
struct comp {
    bool operator()(Mine const & a, Mine const & b) {
        return a.g >= b.g;
    }
};
set<Mine, comp> Set;
*/

//__builtin_clz(int); amount of 0 in the begining
//__builtin_ctz(int); amoint of 0 in the end
//__builtin_popcount(int); amount of 1

//memset(dp, -1, sizeof dp);

/////////////////////
#define int long long
int MOD = 1e9 + 7;
#define endl '\n'
////////////////////

template <class T> struct Fenwick {
    vector<T> V;
    Fenwick(int n): V(n) {}
    void add(size_t i, T x) { for (; i < V.size(); i |= i + 1) V[i] += x; }
    T sum(int i) { T r = T(); for (--i; i >= 0; i = (i & (i + 1)) - 1) r += V[i]; return r; }
    T sum(int l, int r) { return sum(r) - sum(l); }
};

//Cartesian tree (Treap)

////////////////////////////////////////////////////////////////////
/////////Segment tree///////////////////////////////////////////////
int f_Minimum(int a, int b) {
    return(min(a, b));
}
int f_Maximum(int a, int b) {
    return(max(a, b));
}
int f_Summarize (int a, int b) {
    return(a + b);
}

class Parameter {
    public:
        int InitialValue;
        int (*Function)(int a, int b);

        Parameter(int (*f)(int a, int b), int value) {
            Function = f;
            InitialValue = value;
        }
    private:
};

Parameter Minimum(f_Minimum, LONG_LONG_MAX);
Parameter Maximum(f_Maximum, LONG_LONG_MIN);
Parameter Summarize(f_Summarize, 0);

class SegmentTree {
    public:
        SegmentTree(int size, Parameter p) {
            Function = p.Function;
            InitialValue = p.InitialValue;
            n = size;
            data = vector<int>(2*n, 0);
        }
        SegmentTree(vector<int> array, Parameter p) {
            Function = p.Function;
            InitialValue = p.InitialValue;
            n = array.size();;
            data = vector<int>(2*n, 0);
            fori(n) {
                data[n + i] = array[i];
            }
            for (int i = n-1; i >= 1; ++i) {
                data[i] = Function(data[i*2], data[i*2]+1);
            }
        }

        void Update(int idx, int value) {
            idx += n;
            data[idx] = value;

            while(idx > 1) {
                idx /= 2;
                data[idx] = Function(data[idx*2], data[idx*2+1]);
            }
        }
        int Find(int left, int right) { // [left; right)
            left += n;
            right += n;

            int value = InitialValue;
            while (left < right) {
                if (left % 2 == 1) {
                    value = Function(left, value);
                    left++;
                }
                if (right % 2 == 1) {
                    value = Function(right, value);
                    right--;
                }
                left /= 2; right /= 2;
            }
            return value;
        }

    private:
        int n;
        vector<int> data;
        int (*Function)(int a, int b);
        int InitialValue;
};
/////////Segment tree///////////////////////////////////////////////
////////////////////////////////////////////////////////////////////

int32_t main() {
    boostIO();
    int n; cin >> n;
    vector<vector<int>> adj(n, vector<int> (0));
    fori(n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    vector<set<int>> A(n);
    vector<int> Colour(n);
    queue<int> Q;
    int max_k = 0;
    Colour[0] = 1;
    A[0].insert(1);
    Q.push(0);
    while(Q.size() > 0) {
        int node = Q.front();
        Q.pop();
        for(auto x : adj[node]) {
            if (Colour[x] == 0) {
                int k = 1;
                while(A[node].find(k) != A[node].end()) {
                    ++k;
                    max_k = max(max_k, k);
                }
                Colour[x] = k;
                A[x].insert(k);
                Q.push(x);
                A[node].insert(k);
                A[x].insert(Colour[node]);
            }
        }
    }
    cout << max_k << endl;
    fori(n) {
        cout << Colour[i] << " ";
    }

    Return;
}


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

ifstream fin("input.txt");
ofstream fout("output.txt");

bool isPrime(long long int x) { if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
    for (int i = 5; i * i <= x; i += 6) if (x % i == 0 || x % (i + 2) == 0) return 0; return 1; }

void primeFactors(long long n, set<long long> &Fac) {
    // Print the number of 2s that divide n
    while (n%2 == 0)
    {
        Fac.insert(2);
        n = n/2;
    }

    // n must be odd at this point.  So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        // While i divides n, print i and divide n
        while (n%i == 0)
        {
            Fac.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        Fac.insert(n);
}
int NumDigits(int x)
{
    //x = abs(x);
    return (x < 10 ? 1 :
        (x < 100 ? 2 :
        (x < 1000 ? 3 :
        (x < 10000 ? 4 :
        (x < 100000 ? 5 :
        (x < 1000000 ? 6 :
        (x < 10000000 ? 7 :
        (x < 100000000 ? 8 :
        (x < 1000000000 ? 9 :
        10)))))))));
}

inline void boostIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    cout.precision(10);
}

typedef long long int ll;
typedef long double ld;

#define fori(n)  for(int i = 0; i < (n); ++i)
#define forj(n)  for(int j = 0; j < (n); ++j)
#define fork(n) for(int k = 0; k < (n); ++k)
#define forx(n) for(int x = 0; x < (n); ++x)

#define LONG_LONG_MAX  9223372036854775807
#define LONG_LONG_MIN   -9223372036854775807
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))

#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " " << x.ff << " " << x.ss << endl;
#define debug_v(x) cerr << #x << " "; for (auto ii : x) cout << ii << " "; cout << endl;
#define debug_vp(x) cerr << #x << " "; for (auto ii : x) cout << '[' << ii.ff << " " << ii.ss << ']'; cout << endl;
#define mp make_pair

#define Return cerr<<endl<<"RUNTIME: "<<1.0*clock()/CLOCKS_PER_SEC << " s" <<endl; return 0;

#define PI 3.14159265

ll Pow10[19] = {(ll)0,(ll)1e1,(ll)1e2,(ll)1e3,(ll)1e4,(ll)1e5,(ll)1e6,(ll)1e7,(ll)1e8,(ll)1e9,(ll)1e10,
                (ll)1e11,(ll)1e12,(ll)1e13,(ll)1e14,(ll)1e15,(ll)1e16,(ll)1e17,(ll)1e18};
//be careful with pow(), cuz it returns NOT AN INTEGER

//int mid = low + ((high - low) / 2);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b);}

struct Mine {
    int g = 0;
    int x = 0;
    int y = 0;
    int X = 0;
    int Y = 0;
};
/*
struct comp {
    bool operator()(Mine const & a, Mine const & b) {
        return a.g >= b.g;
    }
};
set<Mine, comp> Set;
*/

//__builtin_clz(int); amount of 0 in the begining
//__builtin_ctz(int); amoint of 0 in the end
//__builtin_popcount(int); amount of 1

//memset(dp, -1, sizeof dp);

/////////////////////
#define int long long
int MOD = 1e9 + 7;
#define endl '\n'
////////////////////

template <class T> struct Fenwick {
    vector<T> V;
    Fenwick(int n): V(n) {}
    void add(size_t i, T x) { for (; i < V.size(); i |= i + 1) V[i] += x; }
    T sum(int i) { T r = T(); for (--i; i >= 0; i = (i & (i + 1)) - 1) r += V[i]; return r; }
    T sum(int l, int r) { return sum(r) - sum(l); }
};

//Cartesian tree (Treap)

////////////////////////////////////////////////////////////////////
/////////Segment tree///////////////////////////////////////////////
int f_Minimum(int a, int b) {
    return(min(a, b));
}
int f_Maximum(int a, int b) {
    return(max(a, b));
}
int f_Summarize (int a, int b) {
    return(a + b);
}

class Parameter {
    public:
        int InitialValue;
        int (*Function)(int a, int b);

        Parameter(int (*f)(int a, int b), int value) {
            Function = f;
            InitialValue = value;
        }
    private:
};

Parameter Minimum(f_Minimum, LONG_LONG_MAX);
Parameter Maximum(f_Maximum, LONG_LONG_MIN);
Parameter Summarize(f_Summarize, 0);

class SegmentTree {
    public:
        SegmentTree(int size, Parameter p) {
            Function = p.Function;
            InitialValue = p.InitialValue;
            n = size;
            data = vector<int>(2*n, 0);
        }
        SegmentTree(vector<int> array, Parameter p) {
            Function = p.Function;
            InitialValue = p.InitialValue;
            n = array.size();;
            data = vector<int>(2*n, 0);
            fori(n) {
                data[n + i] = array[i];
            }
            for (int i = n-1; i >= 1; ++i) {
                data[i] = Function(data[i*2], data[i*2]+1);
            }
        }

        void Update(int idx, int value) {
            idx += n;
            data[idx] = value;

            while(idx > 1) {
                idx /= 2;
                data[idx] = Function(data[idx*2], data[idx*2+1]);
            }
        }
        int Find(int left, int right) { // [left; right)
            left += n;
            right += n;

            int value = InitialValue;
            while (left < right) {
                if (left % 2 == 1) {
                    value = Function(left, value);
                    left++;
                }
                if (right % 2 == 1) {
                    value = Function(right, value);
                    right--;
                }
                left /= 2; right /= 2;
            }
            return value;
        }

    private:
        int n;
        vector<int> data;
        int (*Function)(int a, int b);
        int InitialValue;
};
/////////Segment tree///////////////////////////////////////////////
////////////////////////////////////////////////////////////////////

int32_t main() {
    boostIO();
    int n; cin >> n;
    vector<vector<int>> adj(n, vector<int> (0));
    fori(n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    vector<unordered_set<int>> A(n);
    vector<int> Colour(n);
    queue<int> Q;
    int max_k = 0;
    Colour[0] = 1;
    A[0].insert(1);
    Q.push(0);
    while(Q.size() > 0) {
        int node = Q.front();
        Q.pop();
        for(auto x : adj[node]) {
            if (Colour[x] == 0) {
                int k = 1;
                while(A[node].find(k) != A[node].end()) {
                    ++k;
                    max_k = max(max_k, k);
                }
                Colour[x] = k;
                A[x].insert(k);
                Q.push(x);
                A[node].insert(k);
                A[x].insert(Colour[node]);
            }
        }
    }
    cout << max_k << endl;
    fori(n) {
        cout << Colour[i] << " ";
    }

    Return;
}


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

ifstream fin("input.txt");
ofstream fout("output.txt");

bool isPrime(long long int x) { if (x <= 4 || x % 2 == 0 || x % 3 == 0) return x == 2 || x == 3;
    for (int i = 5; i * i <= x; i += 6) if (x % i == 0 || x % (i + 2) == 0) return 0; return 1; }

void primeFactors(long long n, set<long long> &Fac) {
    // Print the number of 2s that divide n
    while (n%2 == 0)
    {
        Fac.insert(2);
        n = n/2;
    }

    // n must be odd at this point.  So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i+2)
    {
        // While i divides n, print i and divide n
        while (n%i == 0)
        {
            Fac.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        Fac.insert(n);
}
int NumDigits(int x)
{
    //x = abs(x);
    return (x < 10 ? 1 :
        (x < 100 ? 2 :
        (x < 1000 ? 3 :
        (x < 10000 ? 4 :
        (x < 100000 ? 5 :
        (x < 1000000 ? 6 :
        (x < 10000000 ? 7 :
        (x < 100000000 ? 8 :
        (x < 1000000000 ? 9 :
        10)))))))));
}

inline void boostIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    cout.precision(10);
}

typedef long long int ll;
typedef long double ld;

#define fori(n)  for(int i = 0; i < (n); ++i)
#define forj(n)  for(int j = 0; j < (n); ++j)
#define fork(n) for(int k = 0; k < (n); ++k)
#define forx(n) for(int x = 0; x < (n); ++x)

#define LONG_LONG_MAX  9223372036854775807
#define LONG_LONG_MIN   -9223372036854775807
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))

#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define debug(x) cerr << #x << " " << x << endl;
#define debug_p(x) cerr << #x << " " << x.ff << " " << x.ss << endl;
#define debug_v(x) cerr << #x << " "; for (auto ii : x) cout << ii << " "; cout << endl;
#define debug_vp(x) cerr << #x << " "; for (auto ii : x) cout << '[' << ii.ff << " " << ii.ss << ']'; cout << endl;
#define mp make_pair

#define Return cerr<<endl<<"RUNTIME: "<<1.0*clock()/CLOCKS_PER_SEC << " s" <<endl; return 0;

#define PI 3.14159265

ll Pow10[19] = {(ll)0,(ll)1e1,(ll)1e2,(ll)1e3,(ll)1e4,(ll)1e5,(ll)1e6,(ll)1e7,(ll)1e8,(ll)1e9,(ll)1e10,
                (ll)1e11,(ll)1e12,(ll)1e13,(ll)1e14,(ll)1e15,(ll)1e16,(ll)1e17,(ll)1e18};
//be careful with pow(), cuz it returns NOT AN INTEGER

//int mid = low + ((high - low) / 2);
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b);}

 /*
struct Mine {
    int g = 0;
    int x = 0;
    int y = 0;
    int X = 0;
    int Y = 0;
};
/
struct comp {
    bool operator()(Mine const & a, Mine const & b) {
        return a.g >= b.g;
    }
};
set<Mine, comp> Set;
*/

//__builtin_clz(int); amount of 0 in the begining
//__builtin_ctz(int); amoint of 0 in the end
//__builtin_popcount(int); amount of 1

//memset(dp, -1, sizeof dp);

/////////////////////
//#define int long long
int MOD = 1e9 + 7;
#define endl '\n'
////////////////////

template <class T> struct Fenwick {
    vector<T> V;
    Fenwick(int n): V(n) {}
    void add(size_t i, T x) { for (; i < V.size(); i |= i + 1) V[i] += x; }
    T sum(int i) { T r = T(); for (--i; i >= 0; i = (i & (i + 1)) - 1) r += V[i]; return r; }
    T sum(int l, int r) { return sum(r) - sum(l); }
};

//Cartesian tree (Treap)

////////////////////////////////////////////////////////////////////
/////////Segment tree///////////////////////////////////////////////
int f_Minimum(int a, int b) {
    return(min(a, b));
}
int f_Maximum(int a, int b) {
    return(max(a, b));
}
int f_Summarize (int a, int b) {
    return(a + b);
}

class Parameter {
    public:
        int InitialValue;
        int (*Function)(int a, int b);

        Parameter(int (*f)(int a, int b), int value) {
            Function = f;
            InitialValue = value;
        }
    private:
};

Parameter Minimum(f_Minimum, LONG_LONG_MAX);
Parameter Maximum(f_Maximum, LONG_LONG_MIN);
Parameter Summarize(f_Summarize, 0);

class SegmentTree {
    public:
        SegmentTree(int size, Parameter p) {
            Function = p.Function;
            InitialValue = p.InitialValue;
            n = size;
            data = vector<int>(2*n, 0);
        }
        SegmentTree(vector<int> array, Parameter p) {
            Function = p.Function;
            InitialValue = p.InitialValue;
            n = array.size();;
            data = vector<int>(2*n, 0);
            fori(n) {
                data[n + i] = array[i];
            }
            for (int i = n-1; i >= 1; ++i) {
                data[i] = Function(data[i*2], data[i*2]+1);
            }
        }

        void Update(int idx, int value) {
            idx += n;
            data[idx] = value;

            while(idx > 1) {
                idx /= 2;
                data[idx] = Function(data[idx*2], data[idx*2+1]);
            }
        }
        int Find(int left, int right) { // [left; right)
            left += n;
            right += n;

            int value = InitialValue;
            while (left < right) {
                if (left % 2 == 1) {
                    value = Function(left, value);
                    left++;
                }
                if (right % 2 == 1) {
                    value = Function(right, value);
                    right--;
                }
                left /= 2; right /= 2;
            }
            return value;
        }

    private:
        int n;
        vector<int> data;
        int (*Function)(int a, int b);
        int InitialValue;
};
/////////Segment tree///////////////////////////////////////////////
////////////////////////////////////////////////////////////////////

int32_t main() {
    boostIO();
    int n; cin >> n;
    vector<vector<int>> adj(n, vector<int> (0));
    fori(n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    vector<unordered_set<int>> A(n);
    vector<int> Colour(n);
    queue<int> Q;
    int max_k = 0;
    Colour[0] = 1;
    A[0].insert(1);
    Q.push(0);
    while(Q.size() > 0) {
        int node = Q.front();
        Q.pop();
        for(auto x : adj[node]) {
            if (Colour[x] == 0) {
                int k = 1;
                while(A[node].find(k) != A[node].end()) {
                    ++k;
                    max_k = max(max_k, k);
                }
                Colour[x] = k;
                A[x].insert(k);
                Q.push(x);
                A[node].insert(k);
                A[x].insert(Colour[node]);
            }
        }
    }
    cout << max_k << endl;
    fori(n) {
        cout << Colour[i] << " ";
    }

    Return;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
#define mem(a) memset(a,0,sizeof a)
const int maxn = 2e5 +5;
vector < int > node[maxn];
int co[maxn];
int vis[150];
int dfs(int x) {
        mem(vis);
        vis[co[x]] = 1;
        vis[0] = 1;
        for(auto i : node[x]) vis[co[i]] = 1;
        for(auto i : node[x]) {
                int g = 1;
                if(!co[i]) {
                        while(vis[g]) g++;
                        co[i] = g;
                        vis[g] = 1;
                        dfs(i);
                }
        }
}
int main() {
        int n,u,v;
        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        cin >> n;
        for(int i = 1 ; i < n ; i ++) {
                cin >> u >> v;
                node[u].push_back(v);
                node[v].push_back(u);
        }
        mem(co);
        co[1] = 1;
        dfs(1);
        int ans = 1;
        for(int i = 1 ; i <= n ; i ++) ans = max(ans,co[i]);
        cout <<ans <<endl;
        for(int i = 1; i <= n ; i ++) cout <<co[i] <<" ";
        cout <<endl;
        return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
#define mem(a) memset(a,0,sizeof a)
const int maxn = 2e5 +5;
vector < int > node[maxn];
int co[maxn];
int dfs(int x) {
        int vis[400];
        mem(vis);
        vis[co[x]] = 1;
        vis[0] = 1;
        for(auto i : node[x]) vis[co[i]] = 1;
        for(auto i : node[x]) {
                int g = 1;
                if(!co[i]) {
                        while(vis[g]) g++;
                        co[i] = g;
                        vis[g] = 1;
                        dfs(i);
                }
        }
}
int main() {
        int n,u,v;
        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        cin >> n;
        for(int i = 1 ; i < n ; i ++) {
                cin >> u >> v;
                node[u].push_back(v);
                node[v].push_back(u);
        }
        mem(co);
        co[1] = 1;
        dfs(1);
        int ans = 1;
        for(int i = 1 ; i <= n ; i ++) ans = max(ans,co[i]);
        cout <<ans <<endl;
        for(int i = 1; i <= n ; i ++) cout <<co[i] <<" ";
        cout <<endl;
        return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
#define mem(a) memset(a,0,sizeof a)
const int maxn = 2e5 +5;
vector < int > node[maxn];
int co[maxn];
int dfs(int x) {
        int vis[1000];
        mem(vis);
        vis[co[x]] = 1;
        vis[0] = 1;
        for(auto i : node[x]) vis[co[i]] = 1;
        vector < int >q;
        for(auto i : node[x]) {
                int g = 1;

                if(!co[i]) {
                        while(vis[g]) g++;
                        co[i] = g;
                        vis[g] = 1;
                     //   cout <<"node "<<i<<"  co"<<g<<endl;
                        q.push_back(i);
                }
                while(!q.empty()) {
                        dfs(q.back());
                        q.pop_back();
                }
        }
}
int main() {
        int n,u,v;
        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        cin >> n;
        for(int i = 1 ; i < n ; i ++) {
                cin >> u >> v;
                node[u].push_back(v);
                node[v].push_back(u);
        }
        mem(co);
        co[1] = 1;
        dfs(1);
        int ans = 1;
        for(int i = 1 ; i <= n ; i ++) ans = max(ans,co[i]);
        cout <<ans <<endl;
        for(int i = 1; i <= n ; i ++) cout <<co[i] <<" ";
        cout <<endl;
        return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
#define mem(a) memset(a,0,sizeof a)
const int maxn = 2e5 +5;
vector < int > node[maxn];
int co[maxn];
int vis[1000];
vector < int >q;
void dfs(int x) {
        for(auto i : node[x]) {
                if(!co[i]) q.push_back(i);
                else vis[co[i]] = 1;
        }
}
void solve(int x) {
        q.clear();
       // cout<<endl;
        mem(vis);
        dfs(x);
        for(auto i : node[x])  dfs(i);
        int g = 1;
        while(!q.empty()) {
                while(vis[g]) g++;
                int v = q.back();
                q.pop_back();
                //cout <<"node :" <<v<<endl;
                if(co[v]) continue;
                co[v] = g;
                vis[g] = 1;
        }
}
int main() {
        int n,u,v;
        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        cin >> n;
        for(int i = 1 ; i < n ; i ++) {
                cin >> u >> v;
                node[u].push_back(v);
                node[v].push_back(u);
        }
        for(int i = 1 ; i <= n ; i ++) node[i].push_back(i);
        mem(co);
        co[1] = 1;
        solve(1);
        for(int i = 2 ; i <= n ; i ++) {
                if(!co[i]) solve(i);
        }

        int ans = 1;
        for(int i = 1 ; i <= n ; i ++) ans = max(ans,co[i]);
        cout <<ans <<endl;
        for(int i = 1; i <= n ; i ++) cout <<co[i] <<" ";
        cout <<endl;
        return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
using namespace std;
#define mem(a) memset(a,0,sizeof a)
const int maxn = 2e5 +5;
vector < int > node[maxn];
int co[maxn],fco[maxn];
void solve() {
        queue<int >q;
        q.push(1);
        while(!q.empty()) {
                int g = 1;
                int v = q.front();
                q.pop();
                for(auto x: node[v]) {
                        if(!co[x]) {
                                fco[x] = co[v];
                                while( g == co[v] ||g == fco[v] )  g++;
                                co[x] = g;
                                g++;
                                q.push(x);
                        }
                }
        }
}
int main() {
        int n,u,v;
        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        cin >> n;
        for(int i = 1 ; i < n ; i ++) {
                cin >> u >> v;
                node[u].push_back(v);
                node[v].push_back(u);
        }
        mem(co);
        mem(fco);
        co[1] = 1;
        fco[1] = 1;
        solve();
        int ans = 1;
        for(int i = 1 ; i <= n ; i ++) ans = max(ans,co[i]);
        cout <<ans <<endl;
        for(int i = 1; i <= n ; i ++) cout <<co[i] <<" ";
        cout <<endl;
        return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
#define mem(a) memset(a,0,sizeof a)
const int maxn = 2e5 +5;
vector < int > node[maxn];
int co[maxn];
int dfs(int x) {
        int vis[200];
        mem(vis);
        vis[co[x]] = 1;
        vis[0] = 1;
        for(auto i : node[x]) vis[co[i]] = 1;
        for(auto i : node[x]) {
                int g = 1;
                if(!co[i]) {
                        while(vis[g]) g++;
                        co[i] = g;
                        vis[g] = 1;
                        dfs(i);
                }
        }
}
int main() {
        int n,u,v;
        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        cin >> n;
        for(int i = 1 ; i < n ; i ++) {
                cin >> u >> v;
                node[u].push_back(v);
                node[v].push_back(u);
        }
        mem(co);
        co[1] = 1;
        dfs(1);
        int ans = 1;
        for(int i = 1 ; i <= n ; i ++) ans = max(ans,co[i]);
        cout <<ans <<endl;
        for(int i = 1; i <= n ; i ++) cout <<co[i] <<" ";
        cout <<endl;
        return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
#define mem(a) memset(a,0,sizeof a)
const int maxn = 2e5 +5;
vector < int > node[maxn];
int co[maxn];
int dfs(int x) {
        int vis[150];
        mem(vis);
        vis[co[x]] = 1;
        vis[0] = 1;
        for(auto i : node[x]) vis[co[i]] = 1;
        for(auto i : node[x]) {
                int g = 1;
                if(!co[i]) {
                        while(vis[g]) g++;
                        co[i] = g;
                        vis[g] = 1;
                        dfs(i);
                }
        }
}
int main() {
        int n,u,v;
        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        cin >> n;
        for(int i = 1 ; i < n ; i ++) {
                cin >> u >> v;
                node[u].push_back(v);
                node[v].push_back(u);
        }
        mem(co);
        co[1] = 1;
        dfs(1);
        int ans = 1;
        for(int i = 1 ; i <= n ; i ++) ans = max(ans,co[i]);
        cout <<ans <<endl;
        for(int i = 1; i <= n ; i ++) cout <<co[i] <<" ";
        cout <<endl;
        return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
#define mem(a) memset(a,0,sizeof a)
const int maxn = 2e5 +5;
vector < int > node[maxn];
int co[maxn];
int dfs(int x) {
        int vis[100];
        mem(vis);
        vis[co[x]] = 1;
        vis[0] = 1;
        for(auto i : node[x]) vis[co[i]] = 1;
        for(auto i : node[x]) {
                int g = 1;
                if(!co[i]) {
                        while(vis[g]) g++;
                        co[i] = g;
                        vis[g] = 1;
                        dfs(i);
                }
        }
}
int main() {
        int n,u,v;
        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        cin >> n;
        for(int i = 1 ; i < n ; i ++) {
                cin >> u >> v;
                node[u].push_back(v);
                node[v].push_back(u);
        }
        mem(co);
        co[1] = 1;
        dfs(1);
        int ans = 1;
        for(int i = 1 ; i <= n ; i ++) ans = max(ans,co[i]);
        cout <<ans <<endl;
        for(int i = 1; i <= n ; i ++) cout <<co[i] <<" ";
        cout <<endl;
        return 0;
}


#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;
#define mem(a) memset(a,0,sizeof a)
const int maxn = 2e5 +5;
vector < int > node[maxn];
int co[maxn];
int vis[1000];
vector < int >q;
void dfs(int x) {
        for(auto i : node[x])
               vis[co[i]] = 1;

}
void solve(int x) {
        q.clear();
     //   cout<<endl;
        mem(vis);
        for(auto i : node[x])  dfs(i);
        int g = 1;
        while(vis[g]) g++;
        co[x] = g;
}
int main() {
        int n,u,v;
        ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
        cin >> n;
        for(int i = 1 ; i < n ; i ++) {
                cin >> u >> v;
                node[u].push_back(v);
                node[v].push_back(u);
        }
        for(int i = 1 ; i <= n ; i ++) node[i].push_back(i);
        mem(co);
        co[1] = 1;
        for(int i = 2 ; i <= n ; i ++) {
                if(!co[i]) solve(i);
        }

        int ans = 1;
        for(int i = 1 ; i <= n ; i ++) ans = max(ans,co[i]);
        cout <<ans <<endl;
        for(int i = 1; i <= n ; i ++) cout <<co[i] <<" ";
        cout <<endl;
        return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+20;
//题意:n<=2e5的tree 求任意三个相邻顶点都不同色,所需要的颜色种数和上色方案
int n,c[N],ans;
pair<int,int> p[N];
int num[N];//num[i] 点i在出现在多少条边中
vector<int> e[N];
void dfs(int u,int fa)
{
	int k=1;
	for(int i=0;i<e[u].size();i++)
	{
		int v=e[u][i];
		if(v!=fa)
		{
			//保证当前子结点颜色和祖先a,b结点颜色不同 && 兄弟结点的颜色要不同
			while(k==c[u]||k==c[fa])
				k++;
			c[v]=k;
			k++;
			dfs(v,u);
		}
	}
}
int main()
{
	while(cin>>n)
	{
		int u,v;
		for(int i=1;i<=n;i++)
			e[i].clear();
		memset(c,-1,sizeof(c));

		for(int i=1;i<=n-1;i++)
		{
			scanf("%d%d",&p[i].first,&p[i].second);
			u=p[i].first;
			v=p[i].second;

			e[u].push_back(v);
			e[v].push_back(u);
		}
		ans=0;
		c[1]=1;
		dfs(1,0);
		for(int i=1;i<=n;i++)
			ans=max(c[i],ans);
		cout<<ans<<endl;
		for(int i=1;i<=n;i++)
		{
			printf("%d",c[i]);
			if(i==n)
			printf("\n");
			else
			printf(" ");
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+20;
//ÌâÒâ:n<=2e5µÄtree ÇóÈÎÒâÈý¸öÏàÁÚ¶¥µã¶¼²»Í¬É«,ËùÐèÒªµÄÑÕÉ«ÖÖÊýºÍÉÏÉ«·½°¸
int n,c[N];
pair<int,int> p[N];
int num[N];//num[i] µãiÔÚ³öÏÖÔÚ¶àÉÙÌõ±ßÖÐ
vector<int> e[N];
int main()
{
	while(cin>>n)
	{
		int u,v;
		for(int i=1;i<=n;i++)
			e[i].clear();
		memset(c,-1,sizeof(c));
		memset(num,0,sizeof(num));
		for(int i=1;i<=n-1;i++)
		{
			scanf("%d%d",&p[i].first,&p[i].second);
			u=p[i].first;
			v=p[i].second;

			e[u].push_back(v);
			e[v].push_back(u);

			num[u]++;
			num[v]++;
		}
		int ans=0;
		for(int i=1;i<=n;i++)
			ans=max(num[i],ans);
		ans++;
		cout<<ans<<endl;

		int x=0;
		for(int i=1;i<=n;i++)
		{
			if(c[i]==-1)
			{
				c[i]=x%ans;
				x++;
			}
			for(int k=0;k<e[i].size();k++)
			{
				int v=e[i][k];
				if(c[v]==-1)
				{
					c[v]=x%ans;
					x++;
				}
			}
		}
		for(int i=1;i<=n;i++)
		{
			printf("%d",c[i]+1);
			if(i==n)
			printf("\n");
			else
			printf(" ");
		}

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+20;
//ÌâÒâ:n<=2e5µÄtree ÇóÈÎÒâÈý¸öÏàÁÚ¶¥µã¶¼²»Í¬É«,ËùÐèÒªµÄÑÕÉ«ÖÖÊýºÍÉÏÉ«·½°¸
int n,c[N],ans;
pair<int,int> p[N];
int num[N];//num[i] µãiÔÚ³öÏÖÔÚ¶àÉÙÌõ±ßÖÐ
vector<int> e[N];
void dfs(int u,int fa,int a,int b)
{
	int k=1;
	for(int i=0;i<e[u].size();i++)
	{
		int v=e[u][i];
		if(v!=fa)
		{
			for(;k<=ans;k++)
			{
				if(k!=a&&k!=b)
				break;
			}
			c[v]=k;
			k++;
			dfs(v,u,c[v],c[u]);
		}
	}
}
int main()
{
	while(cin>>n)
	{
		int u,v;
		for(int i=1;i<=n;i++)
			e[i].clear();
		memset(c,-1,sizeof(c));
		memset(num,0,sizeof(num));
		for(int i=1;i<=n-1;i++)
		{
			scanf("%d%d",&p[i].first,&p[i].second);
			u=p[i].first;
			v=p[i].second;

			e[u].push_back(v);
			e[v].push_back(u);

			num[u]++;
			num[v]++;
		}
		ans=0;
		for(int i=1;i<=n;i++)
			ans=max(num[i],ans);
		ans++;
		cout<<ans<<endl;
		c[1]=1;
		dfs(1,-1,1,-1);
		for(int i=1;i<=n;i++)
		{
			printf("%d",c[i]);
			if(i==n)
			printf("\n");
			else
			printf(" ");
		}

	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+20;
//题意:n<=2e5的tree 求任意三个相邻顶点都不同色,所需要的颜色种数和上色方案
int n,c[N],ans;
pair<int,int> p[N];
int num[N];//num[i] 点i在出现在多少条边中
vector<int> e[N];
void dfs(int u,int fa)
{
	int k=1;
	for(int i=0;i<e[u].size();i++)
	{
		int v=e[u][i];
		if(v!=fa)
		{
			//保证当前子结点颜色和祖先a,b结点颜色不同 && 兄弟结点的颜色要不同
			while(k==c[u]||k==c[fa])
				k++;
			c[v]=k;
			dfs(v,u);

		}
	}
}
int main()
{
	while(cin>>n)
	{
		int u,v;
		for(int i=1;i<=n;i++)
			e[i].clear();
		memset(c,-1,sizeof(c));

		for(int i=1;i<=n-1;i++)
		{
			scanf("%d%d",&p[i].first,&p[i].second);
			u=p[i].first;
			v=p[i].second;

			e[u].push_back(v);
			e[v].push_back(u);
		}
		ans=0;
		for(int i=1;i<=n;i++)
			ans=max(c[i],ans);
		cout<<ans<<endl;
		c[1]=1;
		dfs(1,-1);
		for(int i=1;i<=n;i++)
		{
			printf("%d",c[i]);
			if(i==n)
			printf("\n");
			else
			printf(" ");
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+20;
//题意:n<=2e5的tree 求任意三个相邻顶点都不同色,所需要的颜色种数和上色方案
int n,c[N],ans;
pair<int,int> p[N];
int num[N];//num[i] 点i在出现在多少条边中
vector<int> e[N];
void dfs(int u,int fa)
{
	int k=1;
	for(int i=0;i<e[u].size();i++)
	{
		int v=e[u][i];
		if(v!=fa)
		{
			//保证当前子结点颜色和祖先a,b结点颜色不同 && 兄弟结点的颜色要不同
			while(k==c[u]||k==c[fa])
				k++;
			c[v]=k;
			dfs(v,u);

		}
	}
}
int main()
{
	while(cin>>n)
	{
		int u,v;
		for(int i=1;i<=n;i++)
			e[i].clear();
		memset(c,-1,sizeof(c));

		for(int i=1;i<=n-1;i++)
		{
			scanf("%d%d",&p[i].first,&p[i].second);
			u=p[i].first;
			v=p[i].second;

			e[u].push_back(v);
			e[v].push_back(u);
		}
		ans=0;
		c[1]=1;
		dfs(1,-1);
		for(int i=1;i<=n;i++)
			ans=max(c[i],ans);
		cout<<ans<<endl;
		for(int i=1;i<=n;i++)
		{
			printf("%d",c[i]);
			if(i==n)
			printf("\n");
			else
			printf(" ");
		}
	}
	return 0;
}