#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
using namespace std;
long long int n, res[200005], cnt = 0, ans[200005];
vector<long long int> g[200005];
vector<long long int> v[200005];
map<long long int, long long int> c;
queue<long long int> q;
void dfs1(long long int node, long long int color) {
  c[node] = color;
  for (auto it : g[node]) {
    if (!c[it]) {
      dfs1(it, color % 2 + 1);
    }
  }
}
void dfs2(long long int node, long long int p) {
  for (auto it : g[node]) {
    if (it != p) {
      dfs2(it, node);
    }
  }
  for (auto it : g[node]) {
    if (c[it] != c[node] && res[it] == 0 && res[node] == 0) {
      cnt++;
      res[it] = cnt;
      res[node] = cnt;
      q.push(it);
      q.push(node);
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long int i = 1; i < n; i++) {
    long long int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs1(1, 1);
  dfs2(1, 1);
  while (!q.empty()) {
    long long int x = q.front();
    q.pop();
    for (auto it : g[x]) {
      if (res[it] == 0) {
        res[it] = res[x];
        q.push(it);
      }
    }
  }
  for (long long int i = 1; i <= n; i++) {
    v[res[i]].push_back(i);
  }
  long long int mn = 0;
  for (long long int i = 1; i <= cnt; i++) {
    mn += (v[i].size() - 1) * 2;
    for (long long int j = 0; j < v[i].size(); j++) {
      ans[v[i][j]] = v[i][(j + 1) % v[i].size()];
    }
  }
  cout << mn << '\n';
  for (long long int i = 1; i <= n; i++) {
    cout << ans[i] << ' ';
  }
}
