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;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vvc = vector<vc>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vull = vector<ull>;
constexpr int INF = 1e9 + 1e7;
constexpr ll INFl = INF;
constexpr ll INFll = 1e18 + 1e16;
void print() { cout << '\n'; }
template <typename T, typename... Args>
void print(T x, Args... args) {
  cout << x << ' ';
  print(args...);
}
template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2> x) {
  os << '(' << x.first << ' ' << x.second << ')';
  return os;
}
template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& x) {
  is >> x.first >> x.second;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& x) {
  for (T& i : x) os << i << ' ';
  return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& x) {
  for (T& i : x) is >> i;
  return is;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2>& A, const pair<T1, T2>& B) {
  return {A.first + B.first, A.second + B.second};
}
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2>& A, const pair<T1, T2>& B) {
  return {A.first - B.first, A.second - B.second};
}
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2>& A) {
  return {-A.first, -A.second};
}
template <typename T1, typename T2>
bool maxe(T1& A, const T2& B) {
  if (B > A) {
    A = B;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
bool mine(T1& A, const T2& B) {
  if (B < A) {
    A = B;
    return 1;
  }
  return 0;
}
struct vertex {
  vi e;
  int second = 1;
  int d = -1;
  int R = 0;
};
int n;
vector<vertex> G;
void in() {
  cin >> n;
  G.resize(n + 1);
  for (auto i = (2); i <= (n); ++i) {
    int a, b;
    cin >> a >> b;
    G[a].e.emplace_back(b);
    G[b].e.emplace_back(a);
  }
  for (auto i = (1); i <= (n); ++i) G[i].R = i;
}
int dfs0(int v, int p) {
  for (auto u : G[v].e)
    if (u != p) G[v].second += dfs0(u, v);
  return G[v].second;
}
int centroid(int v, int p) {
  for (auto u : G[v].e)
    if (u != p && 2 * G[u].second > n) {
      G[v].second = n - G[u].second;
      return centroid(u, v);
    }
  return v;
}
int dfs1(int v, int p) {
  G[v].d = G[p].d + 1;
  for (auto u : G[v].e)
    if (u != p) G[v].second += dfs1(u, v);
  return G[v].second;
}
vector<vector<int>> T;
void dfs2(int v, int p) {
  T.back().emplace_back(v);
  for (auto u : G[v].e)
    if (u != p) dfs2(u, v);
}
ll solve() {
  dfs0(1, 1);
  int second = centroid(1, 1);
  for (auto v = (1); v <= (n); ++v) G[v].second = 1;
  dfs1(second, second);
  sort(G[second].e.begin(), G[second].e.end(),
       [](int a, int b) { return G[a].second > G[b].second; });
  for (auto v : G[second].e) {
    T.emplace_back();
    dfs2(v, second);
  }
  queue<int> Q;
  for (auto v : T[0]) Q.emplace(v);
  for (auto i = (1); i <= (T.size() - 1); ++i) {
    for (auto v : T[i]) {
      G[v].R = Q.front();
      Q.pop();
      Q.emplace(v);
    }
  }
  for (auto v : T[0]) {
    G[v].R = Q.front();
    Q.pop();
  }
  swap(G[second].R, G[G[second].e[0]].R);
  ll R = 0;
  for (auto i = (1); i <= (n); ++i) R += 2 * G[i].d;
  print(R);
  for (auto i = (1); i <= (n); ++i) cout << G[i].R << ' ';
  cout << '\n';
  return -INF;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int noOfTests = 1;
  while (noOfTests-- > 0) {
    in();
    ll result = solve();
    if (result == ll(-'t'))
      cout << "TAK\n";
    else if (result == ll(-'n'))
      cout << "NIE\n";
    else if (result == ll(-'y'))
      cout << "YES\n";
    else if (result == ll(-'o'))
      cout << "NO\n";
    else if (result == ll(-'e'))
      cout << "Popsute\n";
    else if (result != -INF)
      cout << result << '\n';
  }
  return 0;
}