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>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
using ll = long long;
using namespace std;
string to_string(string s) { return s; }
string to_string(bool b) { return b ? "true" : "false"; }
string to_string(char c) { return string(1, c); }
string to_string(const char *s) { return (string)s; }
template <class A, class B>
string to_string(pair<A, B>);
template <class T>
string to_string(T v) {
  string s = "{", sep = "";
  for (auto x : v) {
    s += sep;
    sep = ", ";
    s += to_string(x);
  }
  return s + "}";
}
template <class A, class B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void dbgPrint() { cerr << endl; }
template <class A, class... B>
void dbgPrint(A a, B... b) {
  cerr << ' ' << to_string(a);
  dbgPrint(b...);
}
namespace IO {
template <class A, class B>
ostream &operator<<(ostream &out, vector<pair<A, B>> a);
template <class A>
ostream &operator<<(ostream &out, vector<A> a);
template <class A, class B>
ostream &operator<<(ostream &out, pair<A, B> a) {
  out << a.first << " " << a.second;
  return out;
}
template <class A, class B>
ostream &operator<<(ostream &out, vector<pair<A, B>> a) {
  for (pair<A, B> x : a) out << x.first << " " << x.second << '\n';
  return out;
}
template <class A>
ostream &operator<<(ostream &out, vector<A> a) {
  for (A x : a) out << x << ' ';
  return out;
}
template <class A, class B>
istream &operator>>(istream &in, pair<A, B> &a) {
  in >> a.first >> a.second;
  return in;
}
template <class A>
istream &operator>>(istream &in, vector<A> &a) {
  for (A &x : a) in >> x;
  return in;
}
}  // namespace IO
template <class A, class B>
inline ll chkmax(A &a, B b) {
  if (a < (A)b) {
    a = (A)b;
    return 1;
  }
  return 0;
}
template <class A, class B>
inline ll chkmin(A &a, B b) {
  if (a > (A)b) {
    a = (A)b;
    return 1;
  }
  return 0;
}
using namespace IO;
void solve();
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(41);
  ll q = 1;
  while (q--) solve();
}
const ll N = 1e5 + 2;
vector<ll> g[N];
ll dp[N][2];
ll match[N];
void dfs1(ll v, ll p) {
  ll sum = 0;
  for (ll x : g[v]) {
    if (x != p) {
      dfs1(x, v);
      dp[v][0] += max(dp[x][1], dp[x][0]);
      sum += max(dp[x][0], dp[x][1]);
    }
  }
  for (ll x : g[v]) {
    if (x != p &&
        chkmax(dp[v][1], 1 + dp[x][0] + sum - max(dp[x][0], dp[x][1])))
      match[v] = x;
  }
}
ll sz[N];
ll par[N];
void sizes(ll v, ll p) {
  sz[v] = 1;
  par[v] = p;
  for (ll x : g[v])
    if (x != p) {
      sizes(x, v);
      sz[v] += sz[x];
    }
}
ll get_cent(ll v, ll p, ll n) {
  for (ll x : g[v])
    if (x != p && sz[x] > n / 2) return get_cent(x, v, n);
  return v;
}
vector<ll> tour;
ll ans;
ll subtree(ll v, ll p) {
  tour.emplace_back(v);
  ll t = 1;
  for (ll x : g[v])
    if (x != p) {
      ll tt = subtree(x, v);
      t += tt;
    }
  ans += t * 2;
  return t;
}
vector<ll> g2[N];
ll m[N];
void dfs2(ll v, ll p, ll f) {
  if (f && (((ll)(g[v]).size()) != 1 || v == 0)) {
    ;
    m[v] = match[v];
    m[match[v]] = v;
  }
  for (ll x : g[v]) {
    if (x != p) {
      if (x == m[v])
        dfs2(x, v, 0);
      else {
        if (dp[x][0] > dp[x][1])
          dfs2(x, v, 0);
        else
          dfs2(x, v, 1);
      }
    }
  }
}
void solve() {
  ll n;
  cin >> n;
  for (ll i = (0); i < (ll)(n); ++i) m[i] = -1;
  for (ll i = (0); i < (ll)(n); ++i) match[i] = -1;
  for (ll i = (0); i < (ll)(n - 1); ++i) {
    ll a, b;
    cin >> a >> b;
    --a;
    --b;
    g[a].emplace_back(b);
    g[b].emplace_back(a);
  }
  dfs1(0, 0);
  ll ma = max(dp[0][0], dp[0][1]);
  cout << (2 * ma + 2 * (n - ma * 2)) << '\n';
  dfs2(0, 0, dp[0][0] < dp[0][1]);
  for (ll i = (0); i < (ll)(n); ++i) {
    if (m[i] == -1) {
      g2[g[i][0]].emplace_back(i);
    }
  }
  vector<ll> res(n);
  vector<ll> u(n);
  for (ll i = (0); i < (ll)(n); ++i) {
    if (m[i] != -1 && !u[i]) {
      res[i] = m[i];
      vector<ll> t2 = g2[i];
      ;
      if (!((ll)(t2).size())) continue;
      if (((ll)(t2).size()) == 1) {
        ll v1 = m[i];
        ll v = i;
        u[v1] = 1;
        res[v] = v1;
        res[v1] = t2[0];
        res[t2[0]] = v;
        continue;
      };
      rotate(t2.begin(), t2.begin() + 1, t2.end());
      for (ll j = (0); j < (ll)(((ll)(t2).size())); ++j) res[t2[j]] = g2[i][j];
    }
  }
  for (ll i = (0); i < (ll)(n); ++i) cout << res[i] + 1 << " ";
}