#include <bits/stdc++.h>
using namespace std;
long long n, a, b, m, d[100007], r, p;
vector<long long> v[100007];
pair<long long, long long> S(long long x, long long y) {
  queue<long long> q;
  long long res = 0;
  for (int i = 0; i < v[x].size(); i++) {
    if (v[x][i] != y) {
      pair<long long, long long> m1 = S(v[x][i], x);
      if (m1.second != 0) {
        q.push(m1.second);
      }
      res += m1.first;
    }
  }
  if (q.size() == 0) {
    return {res, x};
  } else {
    res += 2 + (q.size() - 1) * 2;
    d[x] = q.front();
    long long k = q.front();
    q.pop();
    while (q.size() > 0) {
      d[k] = q.front();
      k = q.front();
      q.pop();
    }
    d[k] = x;
    return {res, 0};
  }
}
int main() {
  cin >> n;
  m = 1;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
    if (v[a].size() > 1) m = a;
    if (v[b].size() > 1) m = b;
  }
  if (n <= 1000) {
    for (int i = 1; i <= n; i++) {
      if (S(i, i).second == 0) {
        cout << S(i, i).first << endl;
        for (int j = 1; j <= n; j++) {
          cout << d[j] << " ";
        }
        return 0;
      }
    }
  }
  cout << S(m, m).first << endl;
  for (int i = 1; i <= n; i++) {
    cout << d[i] << " ";
  }
  cout << endl;
  return 0;
}
