Problem: 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

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e5;
long long par[maxn];
long long pred[maxn];
vector<long long> g[maxn];
long long dp[maxn][2];
pair<vector<pair<long long, long long>>, long long> from[maxn][2];
long long res[maxn];
void calc(long long v, long long p) {
  pred[v] = p;
  vector<pair<long long, long long>> a;
  vector<long long> gg;
  for (long long i = 0; i < g[v].size(); ++i) {
    long long to = g[v][i];
    if (p == to) continue;
    calc(to, v);
    a.push_back({dp[to][0], dp[to][1]});
    gg.push_back(to);
  }
  long long sum0 = 0;
  vector<pair<long long, long long>> fr(a.size());
  for (long long j = 0; j < a.size(); ++j) {
    if (a[j].first > a[j].second)
      fr[j] = {0, gg[j]};
    else
      fr[j] = {1, gg[j]};
    sum0 += max(a[j].first, a[j].second);
  }
  long long id1 = -1;
  long long mx = -1e9;
  for (long long k = 0; k < a.size(); ++k) {
    long long now = sum0 - max(a[k].first, a[k].second) + a[k].first;
    if (mx < now) {
      mx = now;
      id1 = k;
    }
  }
  long long sum1 = mx;
  dp[v][0] = sum0;
  from[v][0] = {fr, -1};
  if (id1 != -1) {
    fr[id1] = {0, gg[id1]};
    dp[v][1] = sum1 + 1;
    from[v][1] = {fr, id1};
  } else
    dp[v][1] = -1e9;
}
void make_ans(long long v, long long type) {
  if (type == 1) {
    par[v] = from[v][type].first[from[v][type].second].second;
    par[from[v][type].first[from[v][type].second].second] = v;
    swap(res[v], res[from[v][type].first[from[v][type].second].second]);
  }
  for (long long i = 0; i < from[v][type].first.size(); ++i) {
    long long to = from[v][type].first[i].second;
    long long typ = from[v][type].first[i].first;
    make_ans(to, typ);
  }
}
long long calcParsoch() {
  calc(0, -1);
  if (dp[0][0] > dp[0][1]) {
    make_ans(0, 0);
    return dp[0][0];
  } else {
    make_ans(0, 1);
    return dp[0][1];
  }
}
void dfs(long long v, long long p) {
  pred[v] = p;
  for (long long i = 0; i < g[v].size(); ++i) {
    long long to = g[v][i];
    if (to != p) dfs(to, v);
  }
}
signed main() {
  cin.tie();
  cout.tie();
  ios_base::sync_with_stdio(false);
  for (long long k = 0; k < maxn; ++k) {
    par[k] = -1;
  }
  long long n;
  cin >> n;
  for (long long i = 0; i < n - 1; ++i) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (long long m = 0; m < n; ++m) {
    res[m] = m;
  }
  long long ans = calcParsoch();
  ans = n + (n - ans * 2);
  cout << ans << "\n";
  long long ver = 0;
  for (long long j = 0; j < n; ++j) {
    if (par[j] != -1) ver = j;
  }
  dfs(ver, -1);
  for (long long l = 0; l < n; ++l) {
    if (par[l] == -1) {
      swap(res[pred[l]], res[l]);
    }
  }
  for (long long i = 0; i < n; ++i) {
    cout << res[i] + 1 << " ";
  }
}