__author__ = 'alexkane'

from sys import stdin

if __name__ == "__main__":
    number_of_sticks = int(stdin.readline().rstrip('\n'))
    second_line = stdin.readline().rstrip('\n')
    sticks = [int(x) for x in second_line.split(' ')]

def execute(number_of_sticks, sticks):
    max = 0
    if number_of_sticks < 4:
        return max
    else:
        sticks.sort()
        sticks.reverse()
        current_max = 0
        i = 1
        while i < len(sticks):
            if sticks[i - 1] - sticks[i] <= 1:
                if current_max == 0:
                    current_max = sticks[i]
                    i += 1
                else:
                    max += current_max * sticks[i]
                    current_max = 0
                    i += 1
            i += 1
        return max

if __name__ == "__main__":
    print(execute(number_of_sticks, sticks))


n = int(input())
maxn = 10**6 + 2
cnt = [0] * maxn
for x in map(int, input().split()):
    cnt[x] += 1
ansv = []
for i in range(maxn - 2, 1, -1):
    ansv += [i] * ((cnt[i] + (cnt[i+1] & 1)) >> 1)
    if cnt[i] > 0:
        cnt[i] += cnt[i+1] & 1
ans = 0
for i in range(1, len(ansv), 2):
    ans += ansv[i] * ansv[i-1]
print(ans)


from sys import stdin

if __name__ == '__main__':
    n = int(input())
    num = list(map(int, stdin.readline().split()))

def solve(n, num):
    nmax = 1000003
    cur = nmax * [0]
    pt = []
    res = 0

    for x in range(len(num)):
        cur[num[x]] += 1

    for i in range(nmax - 3, 1, -1):
        for j in range((((cur[i + 1] % 2) + cur[i]) // 2)):
            pt.append(i)
        if cur[i] > 0:
            cur[i] += cur[i + 1] % 2

    for i in range(1, len(pt), 2):
        res += pt[i - 1] * pt[i]
    return res

if __name__ == '__main__':
    print(solve(n, num))


n=int(input())
l=[int(i) for i in input().split()]
l.sort(reverse=True)
k=[]
i=1
while i<n:
    if l[i-1]-l[i]==1:
        k.append(l[i])
        i+=1
    elif l[i-1]==l[i]:
        k.append(l[i])
        i+=1
    i+=1
ans=0
for i in range(1,len(k),2):
    ans+=k[i]*k[i-1]
print(ans)


n=int(input())
l=[int(i) for i in input().split()]
from collections import Counter
c=Counter(l)
m=max(l)
for i in range(m,-1,-1):
    if c[i]%2:
        c[i]-=1
        if c[i-1]&1:
            c[i-1]+=1
res=[]
ans=0
for i in c:
    res=res+[i]*c[i]
res.sort()
#print(res)
if len(res)<4:
    print(0)
    exit()
for i in range(0,len(res),4):
    ans+=res[i]*res[i+2]
print(ans)


n=int(input())
lst=[*map(int,input().split())]
lst=[*reversed(sorted(lst))]
res,first=[],1
ex=res.extend
for i,x in enumerate(lst[1:]):
    if x!=lst[0]:break
    first+=1
div,mod=first//2,first%2
ex([lst[0]]*div)
prev,elem=mod,lst[0]
count=1
if n>first:
    item=lst[first]
    for i,x in enumerate(lst[first+1:]):
        if item==x:count+=1
        else:
            div,mod=count//2,count%2
            if elem-item==1:
                if prev==1 and mod==1:div+=1;prev=0
                else:prev=mod
            else:prev=mod
            ex([item]*div)
            elem,item,count=item,x,1
    div,mod=count//2,count%2
    if elem-item==1:
        if prev==1 and mod==1:div+=1
    ex([item]*div)
result=0
for i in range(1,len(res),2):
    result+=(res[i]*res[i-1])
print(result)


n=int(input())
lst=[*map(int,input().split())]
lst=[*reversed(sorted(lst))]
count,res=1,[]
ex=res.extend
for i,x in enumerate(lst[1:]):
    if lst[i]==x:count+=1
    else:
        div,mod=count//2,count%2
        ex([lst[i]]*div)
        count=1
        if mod==1 and lst[i]-x==1:count+=1
        last=lst[i]
ex([lst[-1]]*(count//2))
result=0
for i in range(1,len(res),2):
    result+=(res[i]*res[i-1])
print(result)


n=int(input())
lst=[*map(int,input().split())]
lst=[*reversed(sorted(lst))]
res,first=[],1
ex=res.extend
for i,x in enumerate(lst[1:]):
    if x!=lst[0]:break
    first+=1
div,mod=first//2,first%2
ex([lst[0]]*div)
prev,elem=mod,lst[0]
count=1
if n>first:
    item=lst[first]
    for i,x in enumerate(lst[first+1:]):
        if item==x:count+=1
        else:
            div,mod=count//2,count%2
            if elem-item==1:
                if prev==1 and mod==1:div+=1;prev=0
                else:prev=max(mod,prev)
            else:prev=mod
            ex([item]*div)
            elem,item,count=item,x,1
    div,mod=count//2,count%2
    if elem-item==1:
        if prev==1 and mod==1:div+=1
    ex([item]*div)
result=0
for i in range(1,len(res),2):
    result+=(res[i]*res[i-1])
print(result)


n=int(input())
lst=[*map(int,input().split())]
lst=[*reversed(sorted(lst))]
res,first=[],1
ex=res.extend
for i,x in enumerate(lst[1:]):
    if x!=lst[0]:break
    first+=1
div,mod=first//2,first%2
ex([lst[0]]*div)
prev,elem=mod,lst[0]
count=1
if n>first:
    item=lst[first]
    for i,x in enumerate(lst[first+1:]):
        if item==x:count+=1
        else:
            div,mod=count//2,count%2
            if elem-item==1:
                if prev==1 and mod==1:div+=1;prev=0
                else:prev=mod
            else:prev=mod
            ex([item]*div)
            elem,item,count=item,x,1
div,mod=count//2,count%2
if elem-item==1:
    if prev==1 and mod==1:div+=1
ex([item]*div)
result=0
for i in range(1,len(res),2):
    result+=(res[i]*res[i-1])
print(result)


def main():
    input()
    res, it = 0, iter(sorted(map(int, input().split()), reverse=True))
    try:
        while True:
            a, b, c, d = next(it), next(it), next(it), next(it)
            while a > b + 1:
                a, b, c, d = b, c, d, next(it)
            while c > d + 1:
                c, d = d, next(it)
            res += b * d
    except StopIteration:
        print(res)

if __name__ == '__main__':
    main()


n = int(input())
a = [int(i) for i in input().split()]
g = []
s = 0
a.sort(reverse = True)
i = 0
while i<len(a)-1:
    if a[i] == a[i+1] or a[i] == a[i+1]+1:
        g.append(a[i+1])
        del a[i]
        del a[i]
    else:
        del a[i]
g.sort()
if len(g)<2:
    print(0)
elif len(g)%2!=0:
    del g[0]
    j = 0
    while j<len(g)-1:
        s+=g[j]*g[j+1]
        j+=2
    print(s)
else:
    j = 0
    while j<len(g)-1:
        s+=g[j]*g[j+1]
        j+=2
    print(s)


n = int(input())
c = [0]*1000001
m = 0
for i in list(map(int, input().split())):
    c[i] += 1
    if i > m:
        m = i

n = m
while m != 1:
    if c[m] % 2 == 1:
        if c[m-1]:
            c[m] -= 1
            c[m-1] += 1
        else:
            c[m] -= 1
    m -= 1

pos = 0
s = 0
mem = 0

for pos in range(n, 0, -1):
    if mem and c[pos] >= 2:
        c[pos] -= 2
        s += pos*mem
        mem = 0

    s += pos*pos*(c[pos]//4)

    if c[pos] % 4 >= 2:
        mem = pos

print(s)


n = int(input())
c = [0]*1000001
m = 0
for i in list(map(int, input().split())):
    c[i] += 1
    if i > m:
        m = i

n = m
while m != 1:
    if c[m] % 2 == 1:
        if c[m-1]:
            c[m] -= 1
            c[m-1] += 1
        else:
            c[m] -= 1
    m -= 1

pos = 0
s = 0
mem = 0

for pos in range(n+1):
    if c[pos] >= 2:
        if mem:
            s += mem*pos
            mem = 0
        elif c[pos] % 4 >= 2:
            mem = pos
        c[pos] -= 2
    s += pos*pos*(c[pos]//4)

print(s)


n = int(input())
c = [0]*1000001
m = 0
for i in list(map(int, input().split())):
    c[i] += 1
    if i > m:
        m = i

n = m
while m != 1:
    if c[m] % 2 == 1:
        if c[m-1]:
            c[m] -= 1
            c[m-1] += 1
        else:
            c[m] -= 1
    m -= 1

pos = 0
s = 0
mem = 0

for pos in range(n+1):
    if c[pos] >= 2:
        if mem:
            s += mem*pos
            mem = 0
            c[pos] -= 2
        elif c[pos] % 4 >= 2:
            mem = pos
    s += pos*pos*(c[pos]//4)

print(s)


n = int(input())
c = [0]*1000001
m = 0
for i in list(map(int, input().split())):
    c[i] += 1
    if i > m:
        m = i

n = m
while m != 1:
    if c[m] % 2 == 1:
        if c[m-1]:
            c[m] -= 1
            c[m-1] += 1
        else:
            c[m] -= 1
    m -= 1

pos = 0
s = 0
mem = 0

for pos in range(n, 0, -1):
    if c[pos] >= 2:
        if mem:
            s += mem*pos
            mem = 0
            c[pos] -= 2
        elif c[pos] % 4 >= 2:
            mem = pos
    s += pos*pos*(c[pos]//4)

print(s)


from sys import stdin
import functools
import math

def read(): return map(int, stdin.readline().split())

read()
a = sorted(list(read()))
b = []
while len(a) > 1:
  if a[-1] - a[-2] == 0:
    b.append ( a.pop() )
  elif a[-1] - a[-2] == 1:
    b.append ( a.pop()-1 )
  a.pop()

b = list(reversed(b))
ans = 0
while len(b) > 1:
  ans += b[-1]*b[-2]
  b.pop()
  b.pop()

print(ans)


from sys import stdin
import functools
import math

def read(): return map(int, stdin.readline().split())

read()
a = sorted(list(read()))
b = []
while len(a) > 1:
  if a[-1] - a[-2] == 0:
    b.append ( a.pop() )
  elif a[-1] - a[-2] == 1:
    b.append ( a.pop()-1 )
  a.pop()

b = reversed(b)
ans = 0
while len(b) > 1:
  ans += b[-1]*b[-2]
  b.pop()
  b.pop()

print(ans)


from sys import stdin
import functools
import math

def read(): return map(int, stdin.readline().split())

read()
a = sorted(list(read()))
b = []
while len(a) > 1:
  if a[-1] - a[-2] == 0:
    b.append ( a.pop() )
  elif a[-1] - a[-2] == 1:
    b.append ( a.pop()-1 )
  a.pop()

ans = 0
while len(b) > 1:
  ans += b[-1]*b[-2]
  b.pop()
  b.pop()

print(ans)


n = int(input())
a = list(map(int,input().split()))

a = sorted(a)[::-1]

m = 0
total = 0
while(True):
	flag1 = False
	flag2 = False
	for i in range(m,n-1):
		if((a[i] == a[i+1] or a[i] - a[i+1] == 1) and a[i] != -1):
			flag1 = True
			x = a[i+1]
			m = i+2
			break
	for i in range(m,n-1):
		if((a[i] == a[i+1] or a[i] - a[i+1] == 1) and a[i] != -1):
			flag2 = True
			y = a[i+1]
			m = i+2
			break
	if(flag2 == True):
		total += x*y
	else:
		break

print(total)


n=gets.chomp.to_i
a=gets.chomp.split(" ").map{|x| x.to_i}
b=a.sort
i=n-1
x=1
c=0
s=0
while i>=1 do
	if (b[i]==b[i-1])
		x=x*b[i]
		i=i-1
		c=c+1
	else
		if (b[i-1]==b[i]-1)
			x=x*b[i-1]
			i=i-1
			c=c+1
		end
	end
	if c==2
		s=s+x
		x=1
		c=0
	end
i=i-1
end

puts s


n=gets.chomp.to_i
a=gets.chomp.split(" ").map{|x| x.to_i}
b=a.sort
i=n-1
f=0
x=[]
y=[]
while i>=1 do
	if (b[i]==b[i-1])
		x<<(b[i])
		i=i-1
	end
	if x.length==2
		f=1
		break
	end
	if (b[i-1]==b[i]-1)
		y<<(b[i-1])
		i=i-1
	end
i=i-1
end
if f==1
puts x[0]*x[1]
else
	if x.length==0
		if y.length>=2
			puts y[0]*y[1]
		else
			puts 0
		end
	else
		if y.length>=1
			puts x[0]*y[0]
		else
			puts 0
		end
	end
end


n=gets.chomp.to_i
a=gets.chomp.split(" ").map{|x| x.to_i}
b=a.sort
i=n-1
x=[]
y=[]
c=0
while i>=1 do
	if (b[i]==b[i-1])
		x<<(b[i])
		i=i-1
		c=c+1
	end
	if (b[i-1]==b[i]-1)
		y<<(b[i-1])
		i=i-1
		c=c+1
	end
	if c==2
		break
	end
i=i-1
end

if c==2
	if x.length==2
	puts x[0]*x[1]
	else
		if y.length==2
		puts y[0]*y[1]
		else
		puts x[0]*y[0]
		end
	end
else
puts 0
end


gets
a = gets.split.map(&:to_i)

a.sort!

s = 0
t = 0

while a.size > 1
  ta, tb = a[-2..-1]

  if (ta - tb).abs <= 1
    if t == 0
      t = [ta, tb].min
    else
      s += t * [ta, tb].min
      t = 0
    end
    a = a[0..-3]
  else
    a = a[0..-2]
  end
end

puts s


n = gets.to_i
l = Hash.new(0)
ll = Hash.new(0)
gets.split.each{|i| l[i.to_i]+=1}
l = l.sort_by{|key, value| key}.reverse
(0...l.size).each do |i|
    if i > 0 and l[i-1][0] == l[i][0]+1 and l[i-1][1] > 0 and l[i][1] > 0
        ll[l[i][0]] += 1
        l[i-1][1] = 0
        l[i][1] -= 1
    end
    if l[i][1] >= 2
        ll[l[i][0]] += l[i][1]/2
        l[i][1] %= 2
    end
end
ll = ll.sort_by{|key, value| key}.reverse
ans = 0
(0...ll.size).each do |i|
    if ll[i][1] >= 2
        ans += ll[i][1]/2*ll[i][0]*ll[i][0]
        ll[i][1] %= 2
    end
    if ll[i][1] > 0 and i < ll.size-1
        ans += ll[i][0]*ll[i+1][0]
        ll[i][1] = 0
        ll[i+1][1] -= 1
    end
end
puts ans


n = gets.to_i
l = Hash.new(0)
ll = Hash.new(0)
gets.split.each{|i| l[i.to_i]+=1}
l = l.sort_by{|key, value| key}.reverse
(0...l.size).each do |i|
    if l[i][1] >= 2
        ll[l[i][0]] += l[i][1]/2
        l[i][1] %= 2
    end
end
(1...l.size).each do |i|
    if l[i-1][0] == l[i][0]+1 and l[i-1][1] > 0 and l[i][1] > 0
        ll[l[i][0]] += 1
        l[i-1][1] = 0
        l[i][1] = 0
    end
end
ll = ll.sort_by{|key, value| key}.reverse
ans = 0
(0...ll.size).each do |i|
    if ll[i][1] >= 2
        ans += ll[i][1]/2*ll[i][0]*ll[i][0]
        ll[i][1] %= 2
    end
    if ll[i][1] > 0 and i < ll.size-1
        ans += ll[i][0]*ll[i+1][0]
        ll[i][1] = 0
        ll[i+1][1] -= 1
    end
end
puts ans


n = gets.to_i
l = gets.split.map(&:to_i).sort.reverse
ans = 0
a = 0
b = 0
for i in 0...l.size - 1 do
  if l[i] == l[i + 1]
    if a == 0
      a = l[i]
    elsif b == 0
      b = l[i]
      ans += a * b
      a = 0
      b = 0
    end
    l[i] = 0
    l[i + 1] = 0
  elsif l[i] == l[i + 1] + 1
    if a == 0
      a = l[i + 1]
    elsif b == 0
      b = l[i + 1]
      ans += a * b
      a = 0
      b = 0
    end
    l[i] = 0
    l[i + 1] = 0
  end
end
puts ans


# f = File.open 'input.txt', 'r'
f = STDIN

def fuzzy_equal?(a, b)
  a == b || a + 1 == b
end

def find_eql_sticks(n, sticks)
  [*0...(n - 1)].rindex{ |idx| fuzzy_equal? sticks[idx], sticks[idx + 1] }
end

def length(idx, sticks)
  idx ? sticks[idx] : 0
end

def area(width_idx, height_idx, sticks)
  length(width_idx, sticks) * length(height_idx, sticks)
end

def compute(n, sticks)
  first_pair_index = find_eql_sticks(n, sticks)
  second_pair_index = find_eql_sticks(first_pair_index, sticks)
  area(first_pair_index, second_pair_index, sticks)
end

while true
  raw_n = f.gets
  break unless raw_n
  n = raw_n.chomp.to_i
  sticks = f.gets.chomp.split.map &:to_i
  sorted_sticks = sticks.sort
  puts compute(n, sorted_sticks)
end


f = File.open 'input.txt', 'r'
# f = STDIN

def fuzzy_equal?(a, b)
  a == b || a - 1 == b
end

def find_pairs(sticks)
  marked_indices = []
  start_idx = 0
  sticks.each_with_index do |item, idx|
    next if idx < start_idx
    break if idx >= sticks.length - 1
    if fuzzy_equal?(item, sticks[idx + 1])
      start_idx = idx + 2
      marked_indices << sticks[idx + 1]
    end
  end
  marked_indices
end

def area(width, height)
  width * height
end

def total_areas(marked_indices)
  total_area = 0

  marked_indices.each_with_index do |item, idx|
    next if idx % 2 == 0
    total_area += area item, marked_indices[idx - 1]
  end
  total_area
end

def compute(n, sticks)
  marked_indices = find_pairs sticks
  total_areas marked_indices
end

while true
  raw_n = f.gets
  break unless raw_n
  n = raw_n.chomp.to_i
  sticks = f.gets.chomp.split.map &:to_i
  desc_sticks = sticks.sort{ |a, b| b <=> a }
  p compute(n, desc_sticks)
end


# f = File.open 'input.txt', 'r'
f = STDIN

def fuzzy_equal?(a, b)
  a == b || a - 1 == b
end

def find_pairs(sticks)
  marked_indices = []
  start_idx = 0
  sticks.each_with_index do |item, idx|
    next if idx < start_idx
    break if idx >= sticks.length - 1
    if fuzzy_equal?(item, sticks[idx + 1])
      start_idx = idx + 2
      marked_indices << sticks[idx + 1]
    end
  end
  marked_indices
end

def area(width, height)
  width * height
end

def total_areas(marked_indices)
  total_area = 0

  marked_indices.each_with_index do |item, idx|
    next if idx % 2 == 0
    total_area += area item, marked_indices[idx - 1]
  end
  total_area
end

def compute(n, sticks)
  marked_indices = find_pairs sticks
  total_areas marked_indices
end

while true
  raw_n = f.gets
  break unless raw_n
  n = raw_n.chomp.to_i
  sticks = f.gets.chomp.split.map &:to_i
  desc_sticks = sticks.sort{ |a, b| b <=> a }
  p compute(n, desc_sticks)
end


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 2e5 + 7;
set <int> d[N];
int n;
vector <int> g[N];
int c[N];
void dfs(int u, int p) {
    for (int i = 1; ; ++i)
        if (d[p].find(i) == d[p].end()) {
            c[u] = i;
            break;
        }
    if (u != 1)
        d[p].insert(c[u]);
    d[u].insert(c[u]);
    d[u].insert(c[p]);
    for (int v : g[u])
        if (v != p)
            dfs(v, u);
}
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int u , v; cin >> u >> v;
        g[u].app(v); g[v].app(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        ans = max(ans, (int)g[i].size() + 1);
    cout << ans << '\n';
    dfs(1, 1);
    for (int i = 1; i <= n; ++i) cout << c[i] << ' ';
    cout << '\n';
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1e5 + 7;
set <int> d[N];
int n;
vector <int> g[N];
int c[N];
void dfs(int u, int p) {
    for (int i = 1; ; ++i)
        if (d[p].find(i) == d[p].end()) {
            c[u] = i;
            break;
        }
    if (u != 1)
        d[p].insert(c[u]);
    d[u].insert(c[u]);
    d[u].insert(c[p]);
    for (int v : g[u])
        if (v != p)
            dfs(v, u);
}
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int u , v; cin >> u >> v;
        g[u].app(v); g[v].app(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        ans = max(ans, (int)g[i].size());
    cout << ans << '\n';
    dfs(1, 1);
    for (int i = 1; i <= n; ++i) cout << c[i] << ' ';
    cout << '\n';
}


#include<bits/stdc++.h>
using namespace std;
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 2e5 + 7;
unordered_set <int> d[N];
int n;
vector <int> g[N];
int c[N];
void dfs(int u, int p) {
    for (int i = 1; ; ++i)
        if (d[p].find(i) == d[p].end()) {
            c[u] = i;
            break;
        }
    if (u != 1)
        d[p].insert(c[u]);
    d[u].insert(c[u]);
    d[u].insert(c[p]);
    for (int v : g[u])
        if (v != p)
            dfs(v, u);
}
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int u , v; cin >> u >> v;
        g[u].app(v); g[v].app(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        ans = max(ans, (int)g[i].size() + 1);
    cout << ans << '\n';
    dfs(1, 1);
    for (int i = 1; i <= n; ++i) cout << c[i] << ' ';
    cout << '\n';
}


#include<bits/stdc++.h>
using namespace std;
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 2e5 + 7;
unordered_set <int> d[N];
int n;
vector <int> g[N];
int c[N];
int ptr[N];
void dfs(int u, int p) {
    for (int i = ptr[p]; ; ++i)
        if (d[p].find(i) == d[p].end()) {
            c[u] = i;
            break;
        }
    if (u != 1) {
        ptr[p] = c[u] + 1;
        d[p].insert(c[u]);
    }
    d[u].insert(c[u]);
    d[u].insert(c[p]);
    for (int v : g[u])
        if (v != p)
            dfs(v, u);
}
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int u , v; cin >> u >> v;
        g[u].app(v); g[v].app(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        ans = max(ans, (int)g[i].size() + 1);
    cout << ans << '\n';
    for (int i = 1; i <= n; ++i)
        ptr[i] = 1;
    dfs(1, 1);
    for (int i = 1; i <= n; ++i) cout << c[i] << ' ';
    cout << '\n';
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1e5 + 7;
set <int> d[N];
int n;
vector <int> g[N];
int c[N];
void dfs(int u, int p) {
    for (int i = 1; ; ++i)
        if (d[p].find(i) == d[p].end()) {
            c[u] = i;
            break;
        }
    if (u != 1)
        d[p].insert(c[u]);
    d[u].insert(c[u]);
    d[u].insert(c[p]);
    for (int v : g[u])
        if (v != p)
            dfs(v, u);
}
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 0; i < n - 1; ++i) {
        int u , v; cin >> u >> v;
        g[u].app(v); g[v].app(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        ans = max(ans, (int)g[i].size() + 1);
    cout << ans << '\n';
    dfs(1, 1);
    for (int i = 1; i <= n; ++i) cout << c[i] << ' ';
    cout << '\n';
}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll n,t=0,y=1;
vector< vector<ll> > g;
vector<ll> a,par,met;
void prov(ll last){
    if(y==t+1) y=1;
    while(a[last]==y) {y++; if(y==t+1) y=1;}
    if(last!=1 && last!=-1){
            ll i=par[last];
  //if(last==2) cout<<y<<' '<<a[i]<<' '<<a[last]<<endl;
  while( y==a[i]|| y==a[last]){
    y++;
    if(y==t+1) y=1;
    //cout<<y<<endl;
  }
  }

}
void dfs(ll v){
met[v]=1;
for(ll j=0; j<g[v].size(); j++){
ll to=g[v][j];
if(met[to]==0) {par[to]=v; dfs(to);}

}
}
int main() {
cin>>n;
g.resize(n+1);
a.resize(n+1,0);
par.resize(n+1,0);
met.resize(n+1,0);
ll x,y1;
for(ll i=1; i<n; i++){
cin>>x>>y1;
g[x].pb(y1);
g[y1].pb(x);
}
for(ll i=1; i<=n; i++){
t=max(t,(ll)(g[i].size()));
}
t++;
cout<<t<<endl;
queue < pair<ll,ll> > r;
r.push({1,-1});
dfs(1);

while(!r.empty()){
pair<ll,ll> o=r.front();
ll i=o.first, last=o.second;
r.pop();
prov(last);
a[i]=y;
y++;
for(ll j=0; j<g[i].size(); j++){
if(a[g[i][j]]==0) r.push({g[i][j],i});
}
}

for(ll i1=1; i1<=n; i1++) cout<<a[i1]<<' ';
}
/*
8
1 2 1 3 1 4 2 5 3 6 3 7 4 8
*/


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll n,t=0,y=1;
vector< vector<ll> > g;
vector<ll> a,par,met;
void prov(ll last){
    if(y==t+1) y=1;
    if(a[last]==y) y++;
    if(last!=1 && last!=-1){
            ll i=par[last];
  //if(last==2) cout<<y<<' '<<a[i]<<' '<<a[last]<<endl;
  while( y==a[i]|| y==a[last]){
    y++;
    if(y==t+1) y=1;
    //cout<<y<<endl;
  }
  }
  while(y>=t+1){ y--; y++;}
}
void dfs(ll v){
met[v]=1;
for(ll j=0; j<g[v].size(); j++){
ll to=g[v][j];
if(met[to]==0) {par[to]=v; dfs(to);}

}
}
int main() {
cin>>n;
g.resize(n+1);
a.resize(n+1,0);
par.resize(n+1,0);
met.resize(n+1,0);
ll x,y1;
for(ll i=1; i<n; i++){
cin>>x>>y1;
g[x].pb(y1);
g[y1].pb(x);
}
for(ll i=1; i<=n; i++){
t=max(t,(ll)(g[i].size()));
}
t++;
cout<<t<<endl;
queue < pair<ll,ll> > r;
r.push({1,-1});
dfs(1);

while(!r.empty()){
pair<ll,ll> o=r.front();
ll i=o.first, last=o.second;
r.pop();
prov(last);
a[i]=y;
y++;
for(ll j=0; j<g[i].size(); j++){
if(a[g[i][j]]==0) r.push({g[i][j],i});
}
}

for(ll i1=1; i1<=n; i1++) cout<<a[i1]<<' ';
}
/*
8
1 2 1 3 1 4 2 5 3 6 3 7 4 8
*/


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll n,t=0,y=1;
vector< vector<ll> > g;
vector<ll> a,par,met;
void prov(ll last){
    if(y==t+1) y=1;
    if(a[last]==y) y++;
    if(last!=1 && last!=-1){
            ll i=par[last];
  //if(last==2) cout<<y<<' '<<a[i]<<' '<<a[last]<<endl;
  while( y==a[i]|| y==a[last]){
    y++;
    if(y==t+1) y=1;
    //cout<<y<<endl;
  }
  }
  while(y==t+1){ y--; y++;}
}
void dfs(ll v){
met[v]=1;
for(ll j=0; j<g[v].size(); j++){
ll to=g[v][j];
if(met[to]==0) {par[to]=v; dfs(to);}

}
}
int main() {
cin>>n;
g.resize(n+1);
a.resize(n+1,0);
par.resize(n+1,0);
met.resize(n+1,0);
ll x,y1;
for(ll i=1; i<n; i++){
cin>>x>>y1;
g[x].pb(y1);
g[y1].pb(x);
}
for(ll i=1; i<=n; i++){
t=max(t,(ll)(g[i].size()));
}
t++;
cout<<t<<endl;
queue < pair<ll,ll> > r;
r.push({1,-1});
dfs(1);

while(!r.empty()){
pair<ll,ll> o=r.front();
ll i=o.first, last=o.second;
r.pop();
prov(last);
a[i]=y;
y++;
for(ll j=0; j<g[i].size(); j++){
if(a[g[i][j]]==0) r.push({g[i][j],i});
}
}

for(ll i1=1; i1<=n; i1++) cout<<a[i1]<<' ';
}
/*
8
1 2 1 3 1 4 2 5 3 6 3 7 4 8
*/


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll n,t=0,y=1;
vector< vector<ll> > g;
vector<ll> a,par,met;
void prov(ll last){
    if(y==t+1) y=1;
    if(a[last]==y) y++;
    if(last!=1 && last!=-1){
            ll i=par[last];
  //if(last==2) cout<<y<<' '<<a[i]<<' '<<a[last]<<endl;
  while( y==a[i]|| y==a[last]){
    y++;
    if(y==t+1) y=1;
    //cout<<y<<endl;
  }
  }
}
void dfs(ll v){
met[v]=1;
for(ll j=0; j<g[v].size(); j++){
ll to=g[v][j];
if(met[to]==0) {par[to]=v; dfs(to);}

}
}
int main() {
cin>>n;
g.resize(n+1);
a.resize(n+1,0);
par.resize(n+1,0);
met.resize(n+1,0);
ll x,y1;
for(ll i=1; i<n; i++){
cin>>x>>y1;
g[x].pb(y1);
g[y1].pb(x);
}
for(ll i=1; i<=n; i++){
t=max(t,(ll)(g[i].size()));
}
t++;
cout<<t<<endl;
queue < pair<ll,ll> > r;
r.push({1,-1});
dfs(1);

while(!r.empty()){
pair<ll,ll> o=r.front();
ll i=o.first, last=o.second;
r.pop();
prov(last);
a[i]=y;
y++;
for(ll j=0; j<g[i].size(); j++){
if(a[g[i][j]]==0) r.push({g[i][j],i});
}
}

for(ll i1=1; i1<=n; i1++) cout<<a[i1]<<' ';
}
/*
8
1 2 1 3 1 4 2 5 3 6 3 7 4 8
*/


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll n,t=0,y=1;
vector< vector<ll> > g;
vector<ll> a;
void prov(ll i, ll last){
if(a[i]==y|| last==y) y++;
if(y==t+1) y=1;
if(a[i]==y|| last==y) y++;
if(y==t+1) y=1;
}
void dfs(ll i, ll last=-1){
prov(i,last);
for(ll j=0; j<g[i].size(); j++){
ll to=g[i][j];
if(a[to]!=0) continue;
a[to]=y;
dfs(to,i);
}

}
int main() {
cin>>n;
g.resize(n+1);
a.resize(n+1,0);
ll x,y;
for(ll i=1; i<n; i++){
cin>>x>>y;
g[x].pb(y);
g[y].pb(x);
}
for(ll i=1; i<=n; i++){
t=max(t,(ll)(g[i].size()));
}
t++;
cout<<t<<endl;
a[1]=1;
dfs(1);
for(ll i=1; i<=n; i++) cout<<a[i]<<' ';

}


#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
ll n,t=0,y=1;
vector< vector<ll> > g;
vector<ll> a;
void prov(ll i, ll last){
if(a[i]==y|| last==y) y++;
if(y==t+1) y=1;
if(a[i]==y|| last==y) y++;
if(y==t+1) y=1;
}
void dfs(ll i, ll last=-1){
prov(i,last);
for(ll j=0; j<g[i].size(); j++){
ll to=g[i][j];
if(a[to]!=0) continue;
a[to]=y;
dfs(to,i);
}
y=1;
}
int main() {
cin>>n;
g.resize(n+1);
a.resize(n+1,0);
ll x,y;
for(ll i=1; i<n; i++){
cin>>x>>y;
g[x].pb(y);
g[y].pb(x);
}
for(ll i=1; i<=n; i++){
t=max(t,(ll)(g[i].size()));
}
t++;
cout<<t<<endl;
a[1]=1;
dfs(1);
for(ll i=1; i<=n; i++) cout<<a[i]<<' ';

}


#include <bits/stdc++.h>

using namespace std;

/********************************************/
#define tie() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ff first
#define ss second
#define mp make_pair
#define f(i,from,to) for(int i=from;i<to;++i)
#define rev(i,to,from) for(int i=to;i>from;--i)
#define pb push_back
#define eb emplace_back
#define mem(arr,val) memset(arr , val , sizeof arr)
#define all(v) v.begin(),v.end()
/******************************************/

vector <vector <ll> > g;

vector <bool> vis;

vector <ll> pc,sc,gpc;

vector <ll> ac;

template <typename t> maxi (t a , t b) {return  a>b ? a:b ;}

void dfs(ll x ,ll gp, ll p, ll c)
{
    vis[x] = true;
    sc[x] = c;
    pc[x] = p;
    gpc[x] = gp;
    ac.pb(c);
    ll i = 1;
    for(auto node : g[x])
    {
        if(!vis[node])
        {
            ll next = (gpc[x] == 0) ? (maxi(sc[x] , pc[x]) + 1) : gpc[x];
            dfs(node , pc[x] , sc[x] , next);
        }
        pc[x] = sc[node];
    }
    return;
}

void solve()
{
    ll n;cin>>n;

    g.clear();
    g.resize(n);

    vis.clear();
    vis.resize(n,false);

    gpc.clear();
    gpc.resize(n);

    pc.clear();
    pc.resize(n);

    sc.clear();
    sc.resize(n);

    ac.clear();
    f(i,0,n-1)
    {
        ll u,v;cin>>u>>v;

        u--;v--;

        g[u].pb(v);
        g[v].pb(u);
    }

    dfs(0,0,0,1);

    ll mnm = *max_element(all(sc));

    cout<<mnm<<endl;
    for(auto i : sc)
        cout<<i<<" ";
    cout<<endl;

    return;
}

int main()
{
    tie();
    int T=1;
    //cin>>T;
    while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

/**************************************************************/

#define int long long
#define tie() ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f(i,from,to) for(int i = from ; i <to ; i++)
#define mem(a , v) memset(a , v , sizeof a)
#define all(v) v.begin() , v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define what_is(x) cerr << #x << " is : " << x <<endl

const int INF = 1e9 + 7;
const int sz = 1e5 + 20;
const int N =1e5 + 20;
/***************************************************************/

vector <int> g[N];

int clr[N] , c = 0;

void dfs(int x , int color)
{
    clr[x] = color;
    int next = color + 1;
    for(auto node : g[x])
    {
        if(clr[node] == -1)
            dfs(node , (next%c)) , next++;
    }
    return;
}

void solve()
{
    int n;
    cin>>n;

    mem(clr , -1);
    c = 0;
    f(i,0,n-1)
    {
        int u,v;cin>>u>>v;
        u-- , v--;
        g[u].pb(v) , g[v].pb(u);
    }

    f(i,0,n)
        c = max(c , (int)g[i].size() + 1);

    dfs(0 , 0);

    cout<<c<<endl;
    f(i,0,n)
        cout<<clr[i] + 1<<" ";
    cout<<endl;
    return;
}

int32_t main()
{
    clock_t st = clock();
    tie();
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    clog<<(long double)((clock() - st)/CLOCKS_PER_SEC)<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

/********************************************/
#define tie() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ff first
#define ss second
#define mp make_pair
#define f(i,from,to) for(int i=from;i<to;++i)
#define rev(i,to,from) for(int i=to;i>from;--i)
#define pb push_back
#define eb emplace_back
#define mem(arr,val) memset(arr , val , sizeof arr)
#define all(v) v.begin(),v.end()
/******************************************/

vector <vector <ll> > g;

vector <bool> vis;

vector <ll> pc,sc,gpc;

vector <ll> ac;

template <typename t> maxi (t a , t b) {return  a>b ? a:b ;}

void dfs(ll x ,ll gp, ll p, ll c)
{
    vis[x] = true;
    sc[x] = c;
    pc[x] = p;
    gpc[x] = gp;
    ac.pb(c);
    ll i = 1;
    for(auto node : g[x])
    {
        if(!vis[node])
        {
            ll next = (gpc[x] == 0) ? (maxi(sc[x] , pc[x]) + (i++)) : gpc[x];
            dfs(node , pc[x] , sc[x] , next);
        }
    }
    return;
}

void solve()
{
    ll n;cin>>n;

    g.clear();
    g.resize(n);

    vis.clear();
    vis.resize(n,false);

    gpc.clear();
    gpc.resize(n);

    pc.clear();
    pc.resize(n);

    sc.clear();
    sc.resize(n);

    ac.clear();
    f(i,0,n-1)
    {
        ll u,v;cin>>u>>v;

        u--;v--;

        g[u].pb(v);
        g[v].pb(u);
    }

    dfs(0,0,0,1);

    ll mnm = *max_element(all(sc));

    cout<<mnm<<endl;
    for(auto i : sc)
        cout<<i<<" ";
    cout<<endl;

    return;
}

int main()
{
    tie();
    int T=1;
    //cin>>T;
    while(T--)
    solve();
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

/**************************************************************/

#define int long long
#define tie() ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f(i,from,to) for(int i = from ; i <to ; i++)
#define mem(a , v) memset(a , v , sizeof a)
#define all(v) v.begin() , v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define what_is(x) cerr << #x << " is : " << x <<endl

const int INF = 1e9 + 7;
const int sz = 1e5 + 20;
const int N =1e5 + 20;
/***************************************************************/

vector <int> g[N];

int clr[N] , p[N] , c = 0;

void dfs(int x , int color)
{
    clr[x] = color;
    int i = 1;
    for(auto node : g[x])
    {
        if(clr[node] == -1)
        {
            p[node] = clr[x];
            while(i == p[x] or i == clr[x]) i++;
            dfs(node  , i);
            i++;
        }
    }
    return;
}

void solve()
{
    int n;
    cin>>n;

    mem(clr , -1);
    mem(p , -1);
    c = 0;
    f(i,0,n-1)
    {
        int u,v;cin>>u>>v;
        u-- , v--;
        g[u].pb(v) , g[v].pb(u);
    }

    f(i,0,n)
        c = max(c , (int)g[i].size() + 1);

    dfs(0 , 1);

    cout<<c<<endl;
    f(i,0,n)
        cout<<clr[i]<<" ";
    cout<<endl;

    return;
}

int32_t main()
{
    clock_t st = clock();
    tie();
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    clog<<(long double)((clock() - st)/CLOCKS_PER_SEC)<<endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

/**************************************************************/

#define int long long
#define tie() ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f(i,from,to) for(int i = from ; i <to ; i++)
#define mem(a , v) memset(a , v , sizeof a)
#define all(v) v.begin() , v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define what_is(x) cerr << #x << " is : " << x <<endl

const int INF = 1e9 + 7;
const int sz = 1e5 + 20;
const int N =2*1e5 + 20;
/***************************************************************/

vector <int> g[N];

int clr[N] , p[N] , c = 0;

void dfs(int x , int color)
{
    clr[x] = color;
    int i = 1;
    for(auto node : g[x])
    {
        if(clr[node] == -1)
        {
            p[node] = clr[x];
            while(i == p[x] or i == clr[x]) i++;
            dfs(node  , i);
            i++;
        }
    }
    return;
}

void solve()
{
    int n;
    cin>>n;

    mem(clr , -1);
    mem(p , -1);
    c = 0;
    f(i,0,n-1)
    {
        int u,v;cin>>u>>v;
        u-- , v--;
        g[u].pb(v) , g[v].pb(u);
    }

    f(i,0,n)
        c = max(c , (int)g[i].size() + 1);

    dfs(0 , 1);

    cout<<c<<endl;
    f(i,0,n)
        cout<<clr[i]<<" ";
    cout<<endl;

    return;
}

int32_t main()
{
    clock_t st = clock();
    tie();
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    clog<<(long double)((clock() - st)/CLOCKS_PER_SEC)<<endl;
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[200001];
int br[200001],boje[200001],maximum=0,pret[200001];
void dfs(int s,int pret1,bool zauzeto1[200001],int pret2)
{
    //cout << s << " " << pret1 << " " << pret2 << " " << endl;
    int i;
     for(i=0;i<adj[pret2].size();i++)
        if(adj[pret2][i]!=pret1)
            zauzeto1[boje[adj[pret2][i]]]=false;
    for(i=1;i<=maximum;i++)
        if(zauzeto1[i]==false)
        {
            boje[s]=i;
            zauzeto1[i]=true;
            break;
        }

    for(i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]!=pret1)
            dfs(adj[s][i],s,zauzeto1,pret1);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int root,n,i,a,b;
    cin >> n;
    for(i=0;i<n-1;i++)
    {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
        br[a]++;
        br[b]++;
        if(br[a]>maximum)
            maximum=br[a];
        if(br[b]>maximum)
            maximum=br[b];
    }
    maximum++;
    cout << maximum << endl;
    bool zauzeto[200001];
    for(i=1;i<=maximum;i++)
        zauzeto[i]=false;
    dfs(1,0,zauzeto,0);
    for(i=1;i<=n;i++)
        cout << boje[i] << " ";
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[200001];
int br[200001],boje[200001],maximum=0,pret[200001];
void dfs(int s,int pret1,bool zauzeto1[200001])
{
    //cout << s << " " << pret1 << " " << pret2 << " " << endl;
    int i,poc;
    for(i=0;i<adj[pret1].size();i++)
        if(adj[pret1][i]!=s)
            zauzeto1[boje[adj[pret1][i]]]=false;
    poc=1;
    for(i=0;i<adj[s][i];i++)
    {
        if(adj[s][i]!=pret1)
        {
            while(zauzeto1[poc]==true)
                poc++;
            boje[adj[s][i]]=poc;
            zauzeto1[poc]=true;
            poc++;
        }
    }
    //for(i=1;i<=maximum;i++)
      //  if(zauzeto1[i]==false)
        //{
         //   boje[s]=i;
         //   zauzeto1[i]=true;
          //  break;
       // }
    for(i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]!=pret1)
            dfs(adj[s][i],s,zauzeto1);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int root,n,i,a,b;
    cin >> n;
    for(i=0;i<n-1;i++)
    {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
        br[a]++;
        br[b]++;
        if(br[a]>maximum)
            maximum=br[a];
        if(br[b]>maximum)
            maximum=br[b];
    }
    maximum++;
    cout << maximum << endl;
    bool zauzeto[200001];
    for(i=1;i<=maximum;i++)
        zauzeto[i]=false;
    zauzeto[1]=true;
    boje[1]=1;
    dfs(1,0,zauzeto);
    for(i=1;i<=n;i++)
        cout << boje[i] << " ";
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[200001];
int br[200001],boje[200001],maximum=0,pret[200001];
void dfs(int s,int pret1,bool zauzeto1[200001])
{
    //cout << s << " " << pret1 << " " << pret2 << " " << endl;
    int i,poc;
    for(i=0;i<adj[pret1].size();i++)
        if(adj[pret1][i]!=s)
            zauzeto1[boje[adj[pret1][i]]]=false;
    poc=1;
    for(i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]!=pret1)
        {
            while(zauzeto1[poc]==true)
                poc++;
            boje[adj[s][i]]=poc;
            zauzeto1[poc]=true;
            poc++;
        }
    }
    //for(i=1;i<=maximum;i++)
      //  if(zauzeto1[i]==false)
        //{
         //   boje[s]=i;
         //   zauzeto1[i]=true;
          //  break;
       // }
    for(i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]!=pret1)
            dfs(adj[s][i],s,zauzeto1);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int root,n,i,a,b;
    cin >> n;
    for(i=0;i<n-1;i++)
    {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
        br[a]++;
        br[b]++;
        if(br[a]>maximum)
            maximum=br[a];
        if(br[b]>maximum)
            maximum=br[b];
    }
    maximum++;
    cout << maximum << endl;
    bool zauzeto[200001];
    for(i=1;i<=maximum;i++)
        zauzeto[i]=false;
    zauzeto[1]=true;
    boje[1]=1;
    dfs(1,0,zauzeto);
    for(i=1;i<=n;i++)
        cout << boje[i] << " ";
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[200001];
int br[200001],boje[200001],maximum=0,pret[200001];
void dfs(int s,int pret1)
{
    //cout << s << " " << pret1 << " " << pret2 << " " << endl;
    int i,poc;
    poc=1;
    for(i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]!=pret1)
        {
            while(boje[s]==poc || boje[pret1]==poc)
                poc++;
            boje[adj[s][i]]=poc;
            //zauzeto1[poc]=true;
            poc++;
        }
    }
    //for(i=1;i<=maximum;i++)
      //  if(zauzeto1[i]==false)
        //{
         //   boje[s]=i;
         //   zauzeto1[i]=true;
          //  break;
       // }
    for(i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]!=pret1)
            dfs(adj[s][i],s);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int root,n,i,a,b;
    cin >> n;
    for(i=0;i<n-1;i++)
    {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
        br[a]++;
        br[b]++;
        if(br[a]>maximum)
            maximum=br[a];
        if(br[b]>maximum)
            maximum=br[b];
    }
    maximum++;
    cout << maximum << endl;
    boje[1]=1;
    dfs(1,0);
    for(i=1;i<=n;i++)
        cout << boje[i] << " ";
    //cout << "Hello world!" << endl;
    return 0;
}


#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[200001];
int br[200001],boje[200001],maximum=0,pret[200001];
void dfs(int s,int pret1,bool zauzeto1[200001])
{
    //cout << s << " " << pret1 << " " << pret2 << " " << endl;
    int i,poc;
    for(i=0;i<adj[pret1].size();i++)
        if(adj[pret1][i]!=s)
            zauzeto1[boje[adj[pret1][i]]]=false;
    zauzeto1[boje[pret1]]=true;
    poc=1;
    for(i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]!=pret1)
        {
            while(zauzeto1[poc]==true)
                poc++;
            boje[adj[s][i]]=poc;
            zauzeto1[poc]=true;
            poc++;
        }
    }
    //for(i=1;i<=maximum;i++)
      //  if(zauzeto1[i]==false)
        //{
         //   boje[s]=i;
         //   zauzeto1[i]=true;
          //  break;
       // }
    for(i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]!=pret1)
            dfs(adj[s][i],s,zauzeto1);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int root,n,i,a,b;
    cin >> n;
    for(i=0;i<n-1;i++)
    {
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
        br[a]++;
        br[b]++;
        if(br[a]>maximum)
            maximum=br[a];
        if(br[b]>maximum)
            maximum=br[b];
    }
    maximum++;
    cout << maximum << endl;
    bool zauzeto[200001];
    for(i=1;i<=maximum;i++)
        zauzeto[i]=false;
    zauzeto[1]=true;
    boje[1]=1;
    dfs(1,0,zauzeto);
    for(i=1;i<=n;i++)
        cout << boje[i] << " ";
    //cout << "Hello world!" << endl;
    return 0;
}


#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld              long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define dbg(x)          cerr << #x << " = " << x << endl;
#define dbgp(x)         cerr<<"[ "<<#x<<".ff : "<<x.first<<", "<<#x<<".ss : "<<x.second<<" ]"<<endl
#define dbgs(x)         cerr<<"[ "; for(auto i:x) cerr<<i<<" "; cerr<<" ]"<<endl;
#define dbgm(x)         cerr<<"----------"<<endl; for(auto i:x) cerr<<i.fi<<":"<<i.se<<endl; cerr<<"----------";
#define printdb(i)      printf("%.12lf\n",i)
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef map < int, int > mii;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI =           acos(-1);
const int INF =         0x3f3f3f3f;
const ll LINF =         (ll)2e18;
db eps       =          1e-5;
ll mod       =          (1e9+7);    //998244353
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);
    iota(B,B+r,1);

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

const int SIZE=200001;                                //constant SIZE here
bool judge(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}
int n,m,r,u,v,idx=1,k=0;
vvi adj(SIZE);
vii color(SIZE,0), indeg(SIZE,0), outdeg(SIZE,0), level(SIZE,0);
vector <bool> vis(SIZE,false);
stack <int> st;
bool dfs(int u) {
    color[u] = 1;
    bool ans=false;
    for (auto i:adj[u])
    {
        if (color[i] == 1) ans = true;
        if (color[i] == 0 && dfs(i)) ans = true;
    }

    color[u] = 2;
    return ans;
}
set <int> s;
dfs2(int x,int y,int z){
    s.insert(y);
	color[x]=y;
	int j=0,a=1;

	rep(j,0,sz(adj[x])){
		while(a==y||a==z)a++;
		if(color[adj[x][j]]==0)dfs2 (adj[x][j],a,y),a++;
	}
}

int main(){
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
/////////////////////////////////////////////////////////////////////
// Have you thought about it enough?
/////////////////////////////////////////////////////////////////////
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(16);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	cin>>n;
	int vertex=-1;
	rep(i,1,n){
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs2(1,1,0);
	cout<<sz(s)<<endl;
	rep(i,1,n+1) cout<<color[i]<<" ";
	cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld              long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define dbg(x)          cerr << #x << " = " << x << endl;
#define dbgp(x)         cerr<<"[ "<<#x<<".ff : "<<x.first<<", "<<#x<<".ss : "<<x.second<<" ]"<<endl
#define dbgs(x)         cerr<<"[ "; for(auto i:x) cerr<<i<<" "; cerr<<" ]"<<endl;
#define dbgm(x)         cerr<<"----------"<<endl; for(auto i:x) cerr<<i.fi<<":"<<i.se<<endl; cerr<<"----------";
#define printdb(i)      printf("%.12lf\n",i)
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef map < int, int > mii;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI =           acos(-1);
const int INF =         0x3f3f3f3f;
const ll LINF =         (ll)2e18;
db eps       =          1e-5;
ll mod       =          (1e9+7);    //998244353
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);
    iota(B,B+r,1);

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

const int SIZE=1005;                                //constant SIZE here
bool judge(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}
int n,m,r,u,v,idx=1,k=0;
vvi adj(SIZE);
vii color(SIZE,-1), indeg(SIZE,0), outdeg(SIZE,0), level(SIZE,0);
vector <bool> vis(SIZE,false);
stack <int> st;
bool dfs(int u) {
    color[u] = 1;
    bool ans=false;
    for (auto i:adj[u])
    {
        if (color[i] == 1) ans = true;
        if (color[i] == 0 && dfs(i)) ans = true;
    }

    color[u] = 2;
    return ans;
}
vector < set < int > > vv(SIZE);
void dfs2(int u,int par){
	vis[u]=1;
//	dbg(u);
//	dbg(par);
	if(color[u]==-1){
		set < int > s;
		for(auto i:adj[u]) s.insert(color[i]);
		for(auto i:adj[par]) s.insert(color[i]);
		idx=0;
//		dbgs(s);
		while(s.find(idx)!=s.end()){
			idx=(idx+1)%k;
		}
//		dbg(idx);
		color[u]=idx;
	}
	for(auto i:adj[u]){
		if(!vis[i]) dfs2(i,u);
	}
}

int main(){
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////
//  ios_base::sync_with_stdio(false);
//  cin.tie(NULL);
//  cout.tie(NULL);
//  cerr.tie(NULL);
//For fast IO
/////////////////////////////////////////////////////////////////////
// Have you thought about it enough?
/////////////////////////////////////////////////////////////////////
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(16);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	cin>>n;
	rep(i,1,n){
		cin>>u>>v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
		k=max3(k, sz(adj[u]), sz(adj[v]));
	}
	k++;
	cout<<k<<endl;
	color[0]=0;
	vis[0]=1;
	for(auto i: adj[0]) dfs2(i,0);
	rep(i,0,n) cout<<color[i]+1<<" ";
	cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld              long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define dbg(x)          cerr << #x << " = " << x << endl;
#define dbgp(x)         cerr<<"[ "<<#x<<".ff : "<<x.first<<", "<<#x<<".ss : "<<x.second<<" ]"<<endl
#define dbgs(x)         cerr<<"[ "; for(auto i:x) cerr<<i<<" "; cerr<<" ]"<<endl;
#define dbgm(x)         cerr<<"----------"<<endl; for(auto i:x) cerr<<i.fi<<":"<<i.se<<endl; cerr<<"----------";
#define printdb(i)      printf("%.12lf\n",i)
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef map < int, int > mii;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI =           acos(-1);
const int INF =         0x3f3f3f3f;
const ll LINF =         (ll)2e18;
db eps       =          1e-5;
ll mod       =          (1e9+7);    //998244353
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);
    iota(B,B+r,1);

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

const int SIZE=200001;                                //constant SIZE here
bool judge(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}
int n,m,r,u,v,idx=1,k=0;
vvi adj(SIZE);
vii color(SIZE,-1), indeg(SIZE,0), outdeg(SIZE,0), level(SIZE,0);
vector <bool> vis(SIZE,false);
stack <int> st;
bool dfs(int u) {
    color[u] = 1;
    bool ans=false;
    for (auto i:adj[u])
    {
        if (color[i] == 1) ans = true;
        if (color[i] == 0 && dfs(i)) ans = true;
    }

    color[u] = 2;
    return ans;
}
vector < set < int > > vv(SIZE);
void dfs2(int u,int par){
	vis[u]=1;
//	dbg(u);
//	dbg(par);
	if(color[u]==-1){
		set < int > s;
		for(auto i:adj[u]) s.insert(color[i]);
		for(auto i:adj[par]) s.insert(color[i]);
		idx=0;
//		dbgs(s);
		while(s.find(idx)!=s.end()){
			idx=(idx+1)%k;
		}
//		dbg(idx);
		color[u]=idx;
	}
	for(auto i:adj[u]){
		if(!vis[i]) dfs2(i,u);
	}
}

int main(){
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
/////////////////////////////////////////////////////////////////////
// Have you thought about it enough?
/////////////////////////////////////////////////////////////////////
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(16);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	cin>>n;
	int vertex=-1;
	rep(i,1,n){
		cin>>u>>v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
		if(sz(adj[u])>k){
			k=sz(adj[u]);
			vertex=u;
		}
		if(sz(adj[v])>k){
			k=sz(adj[v]);
			vertex=v;
		}
	}
	k++;
	cout<<k<<endl;
	color[vertex]=0;
	vis[vertex]=1;
	for(auto i: adj[vertex]) dfs2(i,vertex);
	rep(i,0,n) cout<<color[i]+1<<" ";
	cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld              long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define dbg(x)          cerr << #x << " = " << x << endl;
#define dbgp(x)         cerr<<"[ "<<#x<<".ff : "<<x.first<<", "<<#x<<".ss : "<<x.second<<" ]"<<endl
#define dbgs(x)         cerr<<"[ "; for(auto i:x) cerr<<i<<" "; cerr<<" ]"<<endl;
#define dbgm(x)         cerr<<"----------"<<endl; for(auto i:x) cerr<<i.fi<<":"<<i.se<<endl; cerr<<"----------";
#define printdb(i)      printf("%.12lf\n",i)
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef map < int, int > mii;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI =           acos(-1);
const int INF =         0x3f3f3f3f;
const ll LINF =         (ll)2e18;
db eps       =          1e-5;
ll mod       =          (1e9+7);    //998244353
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);
    iota(B,B+r,1);

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

const int SIZE=200001;                                //constant SIZE here
bool judge(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}
int n,m,r,u,v,idx=1,k=0;
vvi adj(SIZE);
vii color(SIZE,0), indeg(SIZE,0), outdeg(SIZE,0), level(SIZE,0);
vector <bool> vis(SIZE,false);
stack <int> st;
bool dfs(int u) {
    color[u] = 1;
    bool ans=false;
    for (auto i:adj[u])
    {
        if (color[i] == 1) ans = true;
        if (color[i] == 0 && dfs(i)) ans = true;
    }

    color[u] = 2;
    return ans;
}
set <int> s;
dfs2(int u,int parc,int c){
	s.insert(c);
	color[u]=c;
	int idx=1;
    while(idx==parc || idx==c) idx++;
	for(auto i:adj[u]){
		 if(color[i]==0) dfs2(i,c,idx),idx++;
	}
}

int main(){
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
/////////////////////////////////////////////////////////////////////
// Have you thought about it enough?
/////////////////////////////////////////////////////////////////////
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(16);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	cin>>n;
	int vertex=-1;
	rep(i,1,n){
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs2(1,0,1);
	cout<<((sz(s)))<<endl;
	rep(i,1,n+1) cout<<color[i]<<" ";
	cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld              long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define dbg(x)          cerr << #x << " = " << x << endl;
#define dbgp(x)         cerr<<"[ "<<#x<<".ff : "<<x.first<<", "<<#x<<".ss : "<<x.second<<" ]"<<endl
#define dbgs(x)         cerr<<"[ "; for(auto i:x) cerr<<i<<" "; cerr<<" ]"<<endl;
#define dbgm(x)         cerr<<"----------"<<endl; for(auto i:x) cerr<<i.fi<<":"<<i.se<<endl; cerr<<"----------";
#define printdb(i)      printf("%.12lf\n",i)
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef map < int, int > mii;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI =           acos(-1);
const int INF =         0x3f3f3f3f;
const ll LINF =         (ll)2e18;
db eps       =          1e-5;
ll mod       =          (1e9+7);    //998244353
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);
    iota(B,B+r,1);

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

const int SIZE=200001;                                //constant SIZE here
bool judge(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}
int n,m,r,u,v,idx=1,k=0;
vvi adj(SIZE);
vii color(SIZE,-1), indeg(SIZE,0), outdeg(SIZE,0), level(SIZE,0);
vector <bool> vis(SIZE,false);
stack <int> st;
bool dfs(int u) {
    color[u] = 1;
    bool ans=false;
    for (auto i:adj[u])
    {
        if (color[i] == 1) ans = true;
        if (color[i] == 0 && dfs(i)) ans = true;
    }

    color[u] = 2;
    return ans;
}
set <int> dist;
void dfs2(int u,int par){
	vis[u]=1;
//	dbg(u);
//	dbg(par);

		set < int > s;
		for(auto i:adj[u]) s.insert(color[i]);
		for(auto i:adj[par]) s.insert(color[i]);
		idx=0;
//		dbgs(s);
		while(s.find(idx)!=s.end()){
			idx++;
		}
//		dbg(idx);
		color[u]=idx;
		dist.insert(idx);

	for(auto i:adj[u]){
		if(color[i]==-1) dfs2(i,u);
	}
}

int main(){
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
/////////////////////////////////////////////////////////////////////
// Have you thought about it enough?
/////////////////////////////////////////////////////////////////////
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(16);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	cin>>n;
	rep(i,1,n){
		cin>>u>>v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	for(auto i: adj[0]) if(color[i]==-1) dfs2(i,0);
	cout<<sz(dist)<<endl;
	rep(i,0,n) cout<<color[i]+1<<" ";
	cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld              long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define dbg(x)          cerr << #x << " = " << x << endl;
#define dbgp(x)         cerr<<"[ "<<#x<<".ff : "<<x.first<<", "<<#x<<".ss : "<<x.second<<" ]"<<endl
#define dbgs(x)         cerr<<"[ "; for(auto i:x) cerr<<i<<" "; cerr<<" ]"<<endl;
#define dbgm(x)         cerr<<"----------"<<endl; for(auto i:x) cerr<<i.fi<<":"<<i.se<<endl; cerr<<"----------";
#define printdb(i)      printf("%.12lf\n",i)
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef map < int, int > mii;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI =           acos(-1);
const int INF =         0x3f3f3f3f;
const ll LINF =         (ll)2e18;
db eps       =          1e-5;
ll mod       =          (1e9+7);    //998244353
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);
    iota(B,B+r,1);

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

const int SIZE=200001;                                //constant SIZE here
bool judge(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}
int n,m,r,u,v,idx=1,k=0;
vvi adj(SIZE);
vii color(SIZE,0), indeg(SIZE,0), outdeg(SIZE,0), level(SIZE,0);
vector <bool> vis(SIZE,false);
stack <int> st;
bool dfs(int u) {
    color[u] = 1;
    bool ans=false;
    for (auto i:adj[u])
    {
        if (color[i] == 1) ans = true;
        if (color[i] == 0 && dfs(i)) ans = true;
    }

    color[u] = 2;
    return ans;
}
set <int> s;
dfs2(int u,int parc,int c){
	s.insert(c);
	color[u]=c;
	int idx=1;
	for(auto i:adj[u]){
	    while(idx==parc || idx==c) idx++;
		if(color[i]==0) dfs2(i,c,idx),idx++;
	}
}

int main(){
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
/////////////////////////////////////////////////////////////////////
// Have you thought about it enough?
/////////////////////////////////////////////////////////////////////
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(16);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	cin>>n;
	int vertex=-1;
	rep(i,1,n){
		cin>>u>>v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	dfs2(1,0,1);
	cout<<((sz(s)))<<endl;
	rep(i,1,n+1) cout<<color[i]<<" ";
	cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld              long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define dbg(x)          cerr << #x << " = " << x << endl;
#define dbgp(x)         cerr<<"[ "<<#x<<".ff : "<<x.first<<", "<<#x<<".ss : "<<x.second<<" ]"<<endl
#define dbgs(x)         cerr<<"[ "; for(auto i:x) cerr<<i<<" "; cerr<<" ]"<<endl;
#define dbgm(x)         cerr<<"----------"<<endl; for(auto i:x) cerr<<i.fi<<":"<<i.se<<endl; cerr<<"----------";
#define printdb(i)      printf("%.12lf\n",i)
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef map < int, int > mii;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI =           acos(-1);
const int INF =         0x3f3f3f3f;
const ll LINF =         (ll)2e18;
db eps       =          1e-5;
ll mod       =          (1e9+7);    //998244353
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);
    iota(B,B+r,1);

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

const int SIZE=200001;                                //constant SIZE here
bool judge(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}
int n,m,r,u,v,idx=1,k=0;
vvi adj(SIZE);
vii color(SIZE,-1), indeg(SIZE,0), outdeg(SIZE,0), level(SIZE,0);
vector <bool> vis(SIZE,false);
stack <int> st;
bool dfs(int u) {
    color[u] = 1;
    bool ans=false;
    for (auto i:adj[u])
    {
        if (color[i] == 1) ans = true;
        if (color[i] == 0 && dfs(i)) ans = true;
    }

    color[u] = 2;
    return ans;
}
vector < set < int > > vv(SIZE);
void dfs2(int u,int par){
	vis[u]=1;
//	dbg(u);
//	dbg(par);
	if(color[u]==-1){
		set < int > s;
		for(auto i:adj[u]) s.insert(color[i]);
		for(auto i:adj[par]) s.insert(color[i]);
		idx=0;
//		dbgs(s);
		while(s.find(idx)!=s.end()){
			idx=(idx+1)%k;
		}
//		dbg(idx);
		color[u]=idx;
	}
	for(auto i:adj[u]){
		if(!vis[i]) dfs2(i,u);
	}
}

int main(){
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////
//  ios_base::sync_with_stdio(false);
//  cin.tie(NULL);
//  cout.tie(NULL);
//  cerr.tie(NULL);
//For fast IO
/////////////////////////////////////////////////////////////////////
// Have you thought about it enough?
/////////////////////////////////////////////////////////////////////
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(16);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	cin>>n;
	rep(i,1,n){
		cin>>u>>v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
		k=max3(k, sz(adj[u]), sz(adj[v]));
	}
	k++;
	cout<<k<<endl;
	color[0]=0;
	vis[0]=1;
	for(auto i: adj[0]) dfs2(i,0);
	rep(i,0,n) cout<<color[i]+1<<" ";
	cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld              long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define dbg(x)          cerr << #x << " = " << x << endl;
#define dbgp(x)         cerr<<"[ "<<#x<<".ff : "<<x.first<<", "<<#x<<".ss : "<<x.second<<" ]"<<endl
#define dbgs(x)         cerr<<"[ "; for(auto i:x) cerr<<i<<" "; cerr<<" ]"<<endl;
#define dbgm(x)         cerr<<"----------"<<endl; for(auto i:x) cerr<<i.fi<<":"<<i.se<<endl; cerr<<"----------";
#define printdb(i)      printf("%.12lf\n",i)
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef map < int, int > mii;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI =           acos(-1);
const int INF =         0x3f3f3f3f;
const ll LINF =         (ll)2e18;
db eps       =          1e-5;
ll mod       =          (1e9+7);    //998244353
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);
    iota(B,B+r,1);

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

const int SIZE=200001;                                //constant SIZE here
bool judge(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}
int n,m,r,u,v,idx=1,k=0;
vvi adj(SIZE);
vii color(SIZE,-1), indeg(SIZE,0), outdeg(SIZE,0), level(SIZE,0);
vector <bool> vis(SIZE,false);
stack <int> st;
bool dfs(int u) {
    color[u] = 1;
    bool ans=false;
    for (auto i:adj[u])
    {
        if (color[i] == 1) ans = true;
        if (color[i] == 0 && dfs(i)) ans = true;
    }

    color[u] = 2;
    return ans;
}
vector < set < int > > vv(SIZE);
void dfs2(int u,int par){
	vis[u]=1;
//	dbg(u);
//	dbg(par);
	if(color[u]==-1){
		set < int > s;
		for(auto i:adj[u]) s.insert(color[i]);
		for(auto i:adj[par]) s.insert(color[i]);
		idx=0;
//		dbgs(s);
		while(s.find(idx)!=s.end()){
			idx=(idx+1)%k;
		}
//		dbg(idx);
		color[u]=idx;
	}
	for(auto i:adj[u]){
		if(!vis[i]) dfs2(i,u);
	}
}

int main(){
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
/////////////////////////////////////////////////////////////////////
// Have you thought about it enough?
/////////////////////////////////////////////////////////////////////
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(16);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	cin>>n;
	rep(i,1,n){
		cin>>u>>v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
		k=max3(k, sz(adj[u]), sz(adj[v]));
	}
	k++;
	cout<<k<<endl;
	color[0]=0;
	vis[0]=1;
	for(auto i: adj[0]) dfs2(i,0);
	rep(i,0,n) cout<<color[i]+1<<" ";
	cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
//One implementation to rule them all?
#define db              double
#define ll              long long int
#define ld              long double
//#define int           long long int
#define ull             unsigned long long
#define fi              first
#define se              second
#define rep(i,a,n)      for(int i=a;i<n;i++)
#define repr(i,n,b)     for(int i=n;i>=b;i--)
#define endl            '\n'
#define mem(a,b)        memset(a, b, sizeof a)
#define mkp             make_pair
#define pb              push_back
#define max3(a,b,c)     max(a,max(b,c))
#define min3(a,b,c)     min(a,min(b,c))
#define w(t)            int t; cin>>t; while(t--)
#define all(a)          a.begin(), a.end()
#define sz(a)           int((a).size())
#define dbg(x)          cerr << #x << " = " << x << endl;
#define dbgp(x)         cerr<<"[ "<<#x<<".ff : "<<x.first<<", "<<#x<<".ss : "<<x.second<<" ]"<<endl
#define dbgs(x)         cerr<<"[ "; for(auto i:x) cerr<<i<<" "; cerr<<" ]"<<endl;
#define dbgm(x)         cerr<<"----------"<<endl; for(auto i:x) cerr<<i.fi<<":"<<i.se<<endl; cerr<<"----------";
#define printdb(i)      printf("%.12lf\n",i)
#define isOn(S, j)      (S & (1<<j))
#define setBit(S, j)    (S |= (1<<j))
#define clearBit(S, j)  (S &= ~(1<<j))
#define toggleBit(S, j) (S ^= (1<<j))
#define lowBit(S)       (S & (-S))
#define setAll(S, n)    (S = (1<<n)-1)
#define turnOffLastBit(S) ((S) & (S-1))
#define turnOnLastZero(S) ((S) | (S+1))
//Can use tuples in C++17
using namespace std;
typedef map < int, int > mii;
typedef vector < int > vii;
typedef vector < ll > vll;
typedef vector < vii > vvi;
typedef pair < int,int > pii;
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
const db PI =           acos(-1);
const int INF =         0x3f3f3f3f;
const ll LINF =         (ll)2e18;
db eps       =          1e-5;
ll mod       =          (1e9+7);    //998244353
void print(vector <int> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}
void printll(vector <ll> &arr){
    for(int i=0;i<arr.size();i++)
        cout<<arr[i]<<" ";

    cout<<endl;
}

ll ncr(ll n, ll r)
{
    r=min(r,n-r);
    ll A[r],i,j,B[r];
    iota(A,A+r,n-r+1);
    iota(B,B+r,1);

    ll g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    ll ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

const int SIZE=200001;                                //constant SIZE here
bool judge(int a[], int n){
    static int used[SIZE+1];
    for(int i = 1; i <= n; i++) used[i] = 0;
    for(int i = 0; i < n; i++) used[a[i]] = 1;
    for(int i = 1; i <= n; i++) {
        if(!used[i]) return 0;
    }
    return 1;
}
int n,m,r,u,v,idx=1,k=0;
vvi adj(SIZE);
vii color(SIZE,-1), indeg(SIZE,0), outdeg(SIZE,0), level(SIZE,0);
vector <bool> vis(SIZE,false);
stack <int> st;
bool dfs(int u) {
    color[u] = 1;
    bool ans=false;
    for (auto i:adj[u])
    {
        if (color[i] == 1) ans = true;
        if (color[i] == 0 && dfs(i)) ans = true;
    }

    color[u] = 2;
    return ans;
}
vector < set < int > > vv(SIZE);
void dfs2(int u,int par){
	vis[u]=1;
//	dbg(u);
//	dbg(par);
	if(color[u]==-1){
		set < int > s;
		for(auto i:adj[u]) s.insert(color[i]);
		for(auto i:adj[par]) s.insert(color[i]);
		idx=0;
//		dbgs(s);
		while(s.find(idx)!=s.end()){
			idx=(idx+1)%k;
		}
//		dbg(idx);
		color[u]=idx;
	}
	for(auto i:adj[u]){
		if(!vis[i]) dfs2(i,u);
	}
}

int main(){
//CONDITION && cout << "YES" || cout << "NO"; cout << '\n';
//////////////////////////////////////////////////////////////////
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cerr.tie(NULL);
//For fast IO
/////////////////////////////////////////////////////////////////////
// Have you thought about it enough?
/////////////////////////////////////////////////////////////////////
//  std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//  std::cout.precision(16);
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
	cin>>n;
	int vertex=-1;
	rep(i,1,n){
		cin>>u>>v;
		u--;
		v--;
		adj[u].pb(v);
		adj[v].pb(u);
		if(sz(adj[u])>k){
			k=sz(adj[u]);
			vertex=u;
		}
		if(sz(adj[v])>k){
			k=sz(adj[v]);
			vertex=v;
		}
	}
	k++;
	cout<<k<<endl;
	color[vertex]=0;
	vis[vertex]=1;
	for(auto i: adj[vertex]) if(!vis[i]) dfs2(i,vertex);
	rep(i,0,n) cout<<color[i]+1<<" ";
	cout<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
vector<ll> a[200009];
ll mx,v[200009];
void dfs(ll n,ll p,ll k,ll cp)
{
	if(k==v[cp])
		k=1+k%mx;
	v[n]=k;
	for(auto x:a[n])
		if(x!=p)
			{
				k=1+k%mx;
				dfs(x,n,k,p);
			}
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n,l,r;
  cin>>n;
  ll i=0;
  while(i<n-1)
  {
  	cin>>l>>r;
  	a[l].pb(r);
  	a[r].pb(l);
  	i++;
  }
  i=1;
  while(i<=n)
  {
  	if(a[i].size()>mx)
  		mx=a[i].size();
  	i++;
  }
  mx++;
  deb(mx)
  i=1;
  while(i<=n)
  {
  	if(v[i]==0)
  	{
  		dfs(i,-1,1,-1);
  	}
  	i++;
  }
  i=1;
  while(i<=n)
  {
  	cout<<v[i]<<" ";
  	i++;
  }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
vector<ll> a[200009];
ll mx,v[200009];
void dfs(ll n,ll p,ll k,ll cp)
{
	if(cp>0&&k==v[cp])
		k=1+k%mx;
	v[n]=k;
	for(auto x:a[n])
		if(x!=p)
			{
				k=1+k%mx;
				dfs(x,n,k,p);
			}
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n,l,r;
  cin>>n;
  ll i=0;
  while(i<n-1)
  {
  	cin>>l>>r;
  	a[l].pb(r);
  	a[r].pb(l);
  	i++;
  }
  i=1;
  while(i<=n)
  {
  	if(a[i].size()>mx)
  		mx=a[i].size();
  	i++;
  }
  mx++;
  deb(mx)
  i=1;
  while(i<=n)
  {
  	if(v[i]==0)
  	{
  		dfs(i,-1,1,-1);
  	}
  	i++;
  }
  i=1;
  while(i<=n)
  {
  	cout<<v[i]<<" ";
  	i++;
  }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
vector<ll> a[200009];
ll mx,v[200009];
void dfs(ll n,ll p,ll k,ll cp)
{
	v[n]=k;
	for(auto x:a[n])
		if(x!=p)
			{
				k=1+k%mx;
				//Deb(n,p,k);
				//deb(cp)
				while((p>0&&k==v[p]))
					k=1+k%mx;
				dfs(x,n,k,p);
			}
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n,l,r;
  cin>>n;
  ll i=0;
  while(i<n-1)
  {
  	cin>>l>>r;
  	a[l].pb(r);
  	a[r].pb(l);
  	i++;
  }
  i=1;
  while(i<=n)
  {
  	if(a[i].size()>mx)
  		mx=a[i].size();
  	i++;
  }
  mx++;
  deb(mx)
  i=1;
  while(i<=n)
  {
  	if(v[i]==0)
  	{
  		dfs(i,-1,1,-1);
  	}
  	i++;
  }
  i=1;
  while(i<=n)
  {
  	cout<<v[i]<<" ";
  	i++;
  }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
vector<ll> a[200009];
ll mx,v[200009];
void dfs(ll n,ll p,ll k,ll cp)
{
	v[n]=k;
	for(auto x:a[n])
		if(x!=p)
			{
				k=1+k%mx;
				while(k==v[n]||(cp>0&&k==v[cp]))
					k=1+k%mx;
				dfs(x,n,k,p);
			}
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n,l,r;
  cin>>n;
  ll i=0;
  while(i<n-1)
  {
  	cin>>l>>r;
  	a[l].pb(r);
  	a[r].pb(l);
  	i++;
  }
  i=1;
  while(i<=n)
  {
  	if(a[i].size()>mx)
  		mx=a[i].size();
  	i++;
  }
  mx++;
  deb(mx)
  i=1;
  while(i<=n)
  {
  	if(v[i]==0)
  	{
  		dfs(i,-1,1,-1);
  	}
  	i++;
  }
  i=1;
  while(i<=n)
  {
  	cout<<v[i]<<" ";
  	i++;
  }
}


#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp makepair
#define deb(x) cout<<x<<"\n";
#define deB(x,y) cout<<x<<" "<<y<<"\n";
#define Deb(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define all(v) (v).begin(),(v).end()
vector<ll> a[200009];
ll mx,v[200009];
void dfs(ll n,ll p,ll k)
{
	v[n]=k;
	for(auto x:a[n])
		if(x!=p)
			{
				k=1+k%mx;
				dfs(x,n,k);
			}
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  ll n,l,r;
  cin>>n;
  ll i=0;
  while(i<n-1)
  {
  	cin>>l>>r;
  	a[l].pb(r);
  	a[r].pb(l);
  	i++;
  }
  i=1;
  while(i<=n)
  {
  	if(a[i].size()>mx)
  		mx=a[i].size();
  	i++;
  }
  mx++;
  deb(mx)
  i=1;
  while(i<=n)
  {
  	if(v[i]==0)
  	{
  		dfs(i,-1,1);
  	}
  	i++;
  }
  i=1;
  while(i<=n)
  {
  	cout<<v[i]<<" ";
  	i++;
  }
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <ctime>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair < int, int >
#define ull unsigned long long
#define pll pair < ll, ll >
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()

const int inf = (1ll << 30) - 1;
const int maxn = (int) 1e5 + 10;
const int mod = (int) 1e9 + 7;
using namespace std;

vector<int> a[300300];
int n;
pii e[300300];
int m = 0;
int ans[300300];
void dfs(int v, int p, int c, int c2){

    for(int i = 0; i < a[v].size(); i++){
        int ind = a[v][i];
        int to = e[ind].f ^ e[ind].s ^ v;
        if(to == p) continue;
        c = (c+1) % m;
        if(c2 == c)
            c = (c+1) % m
        ans[to] = c;
        dfs(to, v, c, ans[v]);
    }
}
void solve(){
    cin >> n;
    for(int i=1; i < n; i++) {
        cin >> e[i].f >> e[i].s;
        a[e[i].f].pb(i);
        a[e[i].s].pb(i);
    }
    for(int i = 1; i <= n; i++) m = max(ans, (int)a[i].size() + 1);
    dfs(1, 0, 0, -1);
    cout << m << "\n";
    for(int i = 1; i <= n; i++) cout << ans[i]+1 << " ";
}
int main () {
    int t=1;
    //scanf("%d", &t);
    for(int i=1; i <= t; i++){
      //printf("Case #%d\n", i);
      solve();
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <ctime>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair < int, int >
#define ull unsigned long long
#define pll pair < ll, ll >
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()

const int inf = (1ll << 30) - 1;
const int maxn = (int) 1e5 + 10;
const int mod = (int) 1e9 + 7;
using namespace std;

vector<int> a[300300];
int n;
pii e[300300];
int m = 0;
int ans[300300];
void dfs(int v, int p, int c){
    for(int i = 0; i < a[v].size(); i++){
        int ind = a[v][i];
        int to = e[ind].f ^ e[ind].s ^ v;
        if(to == p) continue;
        c = (c+1) % m;
        ans[ind] = c;
        dfs(to, v,  c);
    }
}
void solve(){
    cin >> n;
    for(int i=1; i < n; i++) {
        cin >> e[i].f >> e[i].s;
        a[e[i].f].pb(i);
        a[e[i].s].pb(i);
    }
    for(int i = 1; i <= n; i++) m = max(ans, (int)a[i].size());
    dfs(1, 0, 0);
    cout << m << "\n";
    for(int i = 1; i < n; i++) cout << ans[i] << " ";
}
int main () {
    int t=1;
    //scanf("%d", &t);
    for(int i=1; i <= t; i++){
      //printf("Case #%d\n", i);
      solve();
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <ctime>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair < int, int >
#define ull unsigned long long
#define pll pair < ll, ll >
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()

const int inf = (1ll << 30) - 1;
const int maxn = (int) 1e5 + 10;
const int mod = (int) 1e9 + 7;
using namespace std;

vector<int> a[300300];
int n;
pii e[300300];
int m = 0;
int ans[300300];
void dfs(int v, int p, int c, int c2){

    for(int i = 0; i < a[v].size(); i++){
        int ind = a[v][i];
        int to = e[ind].f ^ e[ind].s ^ v;
        if(to == p) continue;
        c = (c+1) % m;
        if(c2 == c)
            c = (c+1) % m;
        ans[to] = c;
        dfs(to, v, c, ans[v]);
    }
}
void solve(){
    cin >> n;
    for(int i=1; i < n; i++) {
        cin >> e[i].f >> e[i].s;
        a[e[i].f].pb(i);
        a[e[i].s].pb(i);
    }
    for(int i = 1; i <= n; i++) m = max(m, (int)a[i].size() + 1);
    dfs(1, 0, 0, -1);
    cout << m << "\n";
    for(int i = 1; i <= n; i++) cout << ans[i]+1 << " ";
}
int main () {
    int t=1;
    //scanf("%d", &t);
    for(int i=1; i <= t; i++){
      //printf("Case #%d\n", i);
      solve();
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <ctime>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair < int, int >
#define ull unsigned long long
#define pll pair < ll, ll >
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()

const int inf = (1ll << 30) - 1;
const int maxn = (int) 1e5 + 10;
const int mod = (int) 1e9 + 7;
using namespace std;

vector<int> a[300300];
int n;
pii e[300300];
int m = 0;
int ans[300300];
void dfs(int v, int p, int c){
    for(int i = 0; i < a[v].size(); i++){
        int ind = a[v][i];
        int to = e[ind].f ^ e[ind].s ^ v;
        if(to == p) continue;
        c = (c+1) % m;
        ans[ind] = c;
        dfs(to, v,  c);
    }
}
void solve(){
    cin >> n;
    for(int i=1; i < n; i++) {
        cin >> e[i].f >> e[i].s;
        a[e[i].f].pb(i);
        a[e[i].s].pb(i);
    }
    for(int i = 1; i <= n; i++) m = max(m, (int)a[i].size());
    dfs(1, 0, 0);
    cout << m << "\n";
    for(int i = 1; i < n; i++) cout << ans[i] << " ";
}
int main () {
    int t=1;
    //scanf("%d", &t);
    for(int i=1; i <= t; i++){
      //printf("Case #%d\n", i);
      solve();
    }

    return 0;
}


#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <ctime>

#define pb push_back
#define ll long long
#define mp make_pair
#define f first
#define s second
#define pii pair < int, int >
#define ull unsigned long long
#define pll pair < ll, ll >
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)
#define all(s) s.begin(), s.end()
#define sz(a) (int)a.size()

const int inf = (1ll << 30) - 1;
const int maxn = (int) 1e5 + 10;
const int mod = (int) 1e9 + 7;
using namespace std;

vector<int> a[300300];
int n;
pii e[300300];
int m = 0;
int ans[300300];
void dfs(int v, int p, int c, int c2){

    for(int i = 0; i < a[v].size(); i++){
        int ind = a[v][i];
        int to = e[ind].f ^ e[ind].s ^ v;
        if(to == p) continue;
        c = (c+1) % m;
        if(c2 == c)
            c = (c+1) % m;
        ans[to] = c;
        dfs(to, v, c, ans[v]);
    }
}
void solve(){
    cin >> n;
    for(int i=1; i < n; i++) {
        cin >> e[i].f >> e[i].s;
        a[e[i].f].pb(i);
        a[e[i].s].pb(i);
    }
    for(int i = 1; i <= n; i++) m = max(ans, (int)a[i].size() + 1);
    dfs(1, 0, 0, -1);
    cout << m << "\n";
    for(int i = 1; i <= n; i++) cout << ans[i]+1 << " ";
}
int main () {
    int t=1;
    //scanf("%d", &t);
    for(int i=1; i <= t; i++){
      //printf("Case #%d\n", i);
      solve();
    }

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

void bfs(int x);

int n;
int max_color = INT_MIN;
vector<int> v[200001];
bool visited[200001];
int visited_neighbours[200001];
int colors[200002];

int main()
{
    scanf("%d", &n);
    int a, b;
    for (int i = 1; i < n; i++){
        scanf("%d%d", &a, &b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    /* ------------------- */

    for (int i = 1; i <= n; i++){
        int current_degree = v[i].size();
        max_color = max(max_color, current_degree + 1);
    }
    bfs(1);

    printf("%d\n", max_color);
    for (int i = 1; i <= n; i++)
        printf("%d ", colors[i]);

    return 0;
}

void bfs(int x){
    visited[x] = true;
    colors[x] = 1;
    queue<int> q;
    q.push(x);

    int y;
    while (!q.empty()){
        y = q.front();
        q.pop();

        for (int i = 0; i < v[y].size(); i++){
            if (visited[v[y][i]] == false){
                visited[v[y][i]] = true;
                q.push(v[y][i]);
                visited_neighbours[y]++;
                visited_neighbours[v[y][i]]++;
                if (visited_neighbours[y] == colors[y]){
                    visited_neighbours[y]++;
                    visited_neighbours[v[y][i]]++;
                }
                colors[v[y][i]] = visited_neighbours[y];
            }
        }
    }
}


#include <bits/stdc++.h>

using namespace std;

void bfs(int x);

int n;
int max_color = INT_MIN;
vector<int> v[200001];
bool visited[200001];
int colors[200002];
int parent_colors[200002];
int left_bound[200002];

int main()
{
    scanf("%d", &n);
    int a, b;
    for (int i = 1; i < n; i++){
        scanf("%d%d", &a, &b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    /* ------------------- */

    int max_degree_node;
    for (int i = 1; i <= n; i++){
        int current_degree = v[i].size();
        if (current_degree + 1 > max_color){
            max_color = current_degree + 1;
            max_degree_node = i;
        }
        left_bound[i] = 1;
    }

    colors[max_degree_node] = 1;
    visited[max_degree_node] = true;
    for (int i = 0; i < v[max_degree_node].size(); i++){
        colors[v[max_degree_node][i]] = i + 2;
        parent_colors[v[max_degree_node][i]] = 1;
        visited[v[max_degree_node][i]] = true;
    }

    for (int i = 0; i < v[max_degree_node].size(); i++)
        bfs(v[max_degree_node][i]);

    printf("%d\n", max_color);
    for (int i = 1; i <= n; i++)
        printf("%d ", colors[i]);

    return 0;
}

void bfs(int x){
    visited[x] = true;
    queue<int> q;
    q.push(x);

    int y;
    while (!q.empty()){
        y = q.front();
        q.pop();

        for (int i = 0; i < v[y].size(); i++){
            if (visited[v[y][i]] == false){
                visited[v[y][i]] = true;
                q.push(v[y][i]);
                while(left_bound[y] <= max_color  && colors[v[y][i]] == 0){
                    if (left_bound[y] != parent_colors[y] && left_bound[y] != colors[y]){
                        colors[v[y][i]] = left_bound[y];
                        parent_colors[v[y][i]] = colors[y];
                    }
                    left_bound[y]++;
                }
                left_bound[y]++;
            }
        }
    }
}