1387_B1. Village (Minimum)
This problem is split into two tasks. In this task, you are required to find the minimum possible answer. In the task Village (Maximum) you are required to find the maximum possible answer. Each task is worth 50 points.

There are N houses in a certain village. A single villager lives in each of the houses. The houses are connected by roads. Each road connects two houses and is exactly 1 kilometer long. From each house it is possible to reach any other using one or several consecutive roads. In total there are N-1 roads in the village.

One day all villagers decided to move to different houses — that is, after moving each house should again have a single villager living in it, but no villager should be living in the same house as before. We would like to know the smallest possible total length in kilometers of the shortest paths between the old and the new houses for all villagers.

<image>

Example village with seven houses 

For example, if there are seven houses connected by roads as shown on the figure, the smallest total length is 8 km (this can be achieved by moving 1 → 6, 2 → 4, 3 → 1, 4 → 2, 5 → 7, 6 → 3, 7 → 5).

Write a program that finds the smallest total length of the shortest paths in kilometers and an example assignment of the new houses to the villagers.

Input

The first line contains an integer N (1 < N ≤ 10^5). Houses are numbered by consecutive integers 1, 2, …, N.

Then N-1 lines follow that describe the roads. Each line contains two integers a and b (1 ≤ a, b ≤ N, a ≠ b) denoting that there is a road connecting houses a and b.

Output

In the first line output the smallest total length of the shortest paths in kilometers.

In the second line describe one valid assignment of the new houses with the smallest total length: N space-separated distinct integers v_1, v_2, …, v_N. For each i, v_i is the house number where the villager from the house i should move (v_i ≠ i). If there are several valid assignments, output any of those.

Scoring

Subtasks: 

  1. (6 points) N ≤ 10 
  2. (19 points) N ≤ 1 000 
  3. (25 points) No further constraints 

Examples

Input


4
1 2
2 3
3 4


Output


4
2 1 4 3


Input


7
4 2
5 7
3 4
6 3
1 3
4 5


Output


8
3 4 6 2 7 1 5
```python
import os
import sys
from io import BytesIO, IOBase
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline()
 
# ------------------------------
 
def RL(): return map(int, sys.stdin.readline().split())
def RLL(): return list(map(int, sys.stdin.readline().split()))
def N(): return int(input())
def print_list(l):
    print(' '.join(map(str,l)))
# import heapq as hq
# import bisect as bs
# from collections import deque as dq
# from collections import defaultdict as dc 
# from math import ceil,floor,sqrt
# from collections import Counter


n = N()
dic = [set() for _ in range(n+1)]
dic2 = [[] for _ in range(n+1)]
for _ in range(n-1):
    u,v = RL()
    dic[u].add(v)
    dic[v].add(u)
now = [1]
father,gress,leaf = [0]*(n+1),[0]*(n+1),[]
for i in range(2,n+1):
    gress[i] = len(dic[i])-1
    if gress[i]==0:
        leaf.append(i)
while now:
    node = now.pop()
    dic[node].discard(father[node])
    for child in dic[node]:
        father[child] = node 
        now.append(child)
res = 0
ans = [0]*(n+1)
while leaf:
    p = leaf.pop()
    f = father[p]
    if not dic2[p]:
        dic2[f].append(p)
    else:
        t = len(dic2[p])
        res+=t*2
        while t>2:
            t-=2
            a,b = dic2[p].pop(),dic2[p].pop()
            ans[a] = b 
            ans[b] = a 
        if t==1:
            a = dic2[p].pop()
            ans[a] = p 
            ans[p] = a 
        else:
            a,b = dic2[p].pop(),dic2[p].pop()
            ans[a] = p 
            ans[p] = b 
            ans[b] = a 
    gress[f]-=1
    if gress[f]==0:
        leaf.append(f)
p = 1
if not dic2[p]:
    res+=2
    m = dic[p].pop()
    b = ans[m]
    a = ans[b]
    if a!=m:
        ans[a] = b 
        ans[m] = p 
        ans[p] = m 
    else:
        ans[p] = m 
        ans[m] = b 
        ans[b] = p
else:
    t = len(dic2[p])
    res+=t*2
    while t>2:
        t-=2
        a,b = dic2[p].pop(),dic2[p].pop()
        ans[a] = b 
        ans[b] = a 
    if t==1:
        a = dic2[p].pop()
        ans[a] = p 
        ans[p] = a 
    else:
        a,b = dic2[p].pop(),dic2[p].pop()
        ans[a] = p 
        ans[p] = b 
        ans[b] = a 
print(res)
print_list(ans[1:])
```