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 int MAXN = (int)1e5 + 5;
const int INF = (int)1e9;
vector<int> adj[MAXN];
int suff[MAXN][2];
int dp[MAXN][2];
int ans[MAXN];
int n, tot;
void dfs(int v) {
  for (int to : adj[v]) {
    adj[to].erase(find((adj[to]).begin(), (adj[to]).end(), v));
    dfs(to);
  }
  dp[v][0] = dp[v][1] = INF;
  if (adj[v].empty()) {
    dp[v][1] = 0;
    return;
  }
  int cdp[2] = {0, INF};
  for (int to : adj[v]) {
    int ndp[2] = {INF, INF};
    for (int a = 0; a < 2; ++a) {
      for (int b = 0; b < 2; ++b) {
        int c = min(1, a + b);
        ndp[c] = min(ndp[c], cdp[a] + dp[to][b] + 2 * b);
      }
    }
    cdp[0] = ndp[0];
    cdp[1] = ndp[1];
  }
  dp[v][0] = cdp[1];
  dp[v][1] = cdp[0];
}
void restore(int v) {
  int sz = (int)adj[v].size();
  if (sz == 0) {
    return;
  }
  suff[sz][0] = 0;
  suff[sz][1] = INF;
  for (int i = sz - 1; ~i; --i) {
    int to = adj[v][i];
    suff[i][0] = suff[i][1] = INF;
    for (int a = 0; a < 2; ++a) {
      for (int b = 0; b < 2; ++b) {
        int c = min(1, a + b);
        suff[i][c] = min(suff[i][c], suff[i + 1][a] + dp[to][b] + 2 * b);
      }
    }
  }
  int cur;
  if (ans[v] == v && dp[v][0] != INF) {
    cur = 1;
  } else {
    cur = 0;
  }
  vector<int> cyc;
  for (int i = 0; i < sz; ++i) {
    int to = adj[v][i];
    int nxt = -1;
    for (int a = 0; a < 2; ++a) {
      for (int b = 0; b < 2; ++b) {
        if (nxt != -1) {
          break;
        }
        int c = min(1, a + b);
        int cost = suff[i + 1][a] + dp[to][b] + 2 * b;
        if (c == cur && cost == suff[i][cur]) {
          nxt = a;
          if (b) {
            cyc.push_back(to);
          }
        }
      }
    }
    assert(nxt != -1);
    cur = nxt;
  }
  for (int i = 0; i < (int)cyc.size(); ++i) {
    int j = (i + 1) % cyc.size();
    ans[cyc[i]] = cyc[j];
    tot += 2;
  }
  if (ans[v] == v && !cyc.empty()) {
    ans[v] = cyc.front();
    ans[cyc.back()] = v;
  }
  for (int to : adj[v]) {
    restore(to);
  }
}
void solve() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  iota(ans + 1, ans + n + 1, 1);
  dfs(1);
  restore(1);
  if (ans[1] == 1) {
    tot += 2;
    int a = adj[1][0];
    int b = 2;
    while (ans[b] != a) {
      ++b;
    }
    ans[b] = 1;
    ans[1] = a;
  }
  printf("%d\n", tot);
  for (int i = 1; i <= n; ++i) {
    printf("%d ", ans[i]);
  }
}
int main() {
  int tt = 1;
  while (tt--) {
    solve();
  }
  return 0;
}