#include <bits/stdc++.h>
using namespace std;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;
const long long INF = 2 * 1e18;
const long double PI = 3.14159265358979323846;
vector<long long> ed[100005], dist[100005];
long long par[100005], ans = 0, cur[100005], mx = 0;
void dfs(long long n, long long p, long long d) {
  par[n] = p;
  dist[d].push_back(n);
  mx = max(mx, d);
  for (long long i = 0; i < ed[n].size(); i++) {
    long long u = ed[n][i];
    if (u != p) {
      dfs(u, n, d + 1);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    ed[u].push_back(v);
    ed[v].push_back(u);
  }
  for (long long i = 1; i <= n; i++) cur[i] = i;
  dfs(1, 0, 0);
  while (mx > 0) {
    for (long long i = 0; i < dist[mx].size(); i++) {
      long long u = dist[mx][i];
      if (cur[u] != u) continue;
      swap(cur[u], cur[par[u]]);
      ans += 2;
    }
    mx--;
  }
  if (cur[1] == 1) {
    ans += 2;
    swap(cur[1], cur[ed[1][0]]);
  }
  cout << ans << "\n";
  for (long long i = 1; i <= n; i++) cout << cur[i] << " ";
}
