#include <bits/stdc++.h>
using namespace std;
struct UnionFind {
  int n, num;
  vector<int> sz, parent;
  UnionFind() {}
  UnionFind(int n_) : n(n_), num(n_), sz(n_, 1), parent(n_, 0) {
    iota(parent.begin(), parent.end(), 0);
  }
  int find(int x) { return x == parent[x] ? x : parent[x] = find(parent[x]); }
  bool same(int x, int y) { return find(x) == find(y); }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sz[x] < sz[y]) swap(x, y);
    sz[x] += sz[y];
    parent[y] = x;
    num--;
  }
  int size(int x) { return sz[find(x)]; }
  int count() const { return num; }
};
const int N = 100010;
vector<int> e[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    e[u].push_back(v);
    e[v].push_back(u);
  }
  UnionFind uf(n + 1);
  function<int(int, int)> go = [&](int u, int fa) {
    bool ok = false;
    for (int v : e[u]) {
      if (v ^ fa) {
        if (!go(v, u)) {
          uf.unite(u, v);
          ok = true;
        }
      }
    }
    if (!fa && !ok) uf.unite(u, e[u][0]);
    return ok;
  };
  go(1, 0);
  int ans = 0;
  map<int, vector<int>> mp;
  for (int i = 1; i <= n; i++) {
    mp[uf.find(i)].push_back(i);
  }
  vector<int> f(n + 1);
  for (auto &[p, v] : mp) {
    ans += (int)v.size() - 1;
    for (int i = 0; i < v.size(); i++) {
      f[v[i]] = v[(i + 1) % (int)v.size()];
    }
  }
  cout << ans * 2 << '\n';
  for (int i = 1; i <= n; i++) cout << f[i] << ' ';
  cout << '\n';
  return 0;
}
