#include <bits/stdc++.h>
using namespace std;
long long sum = 0;
vector<long long> out;
class node {
 public:
  vector<node*> nbs;
  vector<node*> chld;
  node* parent;
  bool rooted = false;
  long long ind;
  node(long long i) : ind(i) {}
  bool closed = false;
  vector<long long> group;
  void root() {
    rooted = true;
    for (long long i = (0); i < (nbs.size()); i++) {
      chld.push_back(nbs[i]);
      nbs[i]->root(ind);
    }
  }
  void root(long long par) {
    for (long long i = (0); i < (nbs.size()); i++) {
      if (nbs[i]->ind == par) {
        parent = nbs[i];
      } else {
        chld.push_back(nbs[i]);
        nbs[i]->root(ind);
      }
    }
  }
  void dfs() {
    for (long long i = (0); i < (chld.size()); i++) chld[i]->dfs();
    for (long long i = (0); i < (chld.size()); i++)
      if (!chld[i]->closed) closed = true;
    if (closed)
      group.push_back(ind);
    else if (rooted)
      chld[0]->group.push_back(ind);
    else
      parent->group.push_back(ind);
  }
  void eval() {
    for (long long i = (0); i < (chld.size()); i++) chld[i]->eval();
    if (group.size() > 0) {
      sum += 2 * group.size() - 2;
      for (long long i = (0); i < (group.size()); i++) {
        out[group[i] - 1] = group[(i + 1) % group.size()];
      }
    }
  }
};
signed main() {
  ios_base::sync_with_stdio(0);
  long long n;
  cin >> n;
  vector<node> nodes;
  for (long long i = (0); i < (n); i++) nodes.push_back(node(i + 1));
  for (long long i = (0); i < (n - 1); i++) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    nodes[x].nbs.push_back(&nodes[y]);
    nodes[y].nbs.push_back(&nodes[x]);
  }
  for (long long i = (0); i < (n); i++) out.push_back(-1);
  nodes[0].root();
  nodes[0].dfs();
  nodes[0].eval();
  cout << sum << "\n";
  for (long long i = (0); i < (n); i++) {
    cout << out[i] << " ";
  }
  return 0;
}
