#include <bits/stdc++.h>   using namespace std;   long long a, b, c, d, i, e, f, g, n, m, k, l, A[500005], B[500005], fix[500005],       root, ans, C[500005];   vector<long long> v[500005];   void dfs(long long x, long long y) {     for (long long i = 0; i < v[x].size(); i++) {       if (v[x][i] == y) continue;       dfs(v[x][i], x);       if (fix[v[x][i]] == 0) C[x]++;     }     if (C[x] == 0) return;     root = x;     fix[x] = 1;     for (long long i = 0; i < v[x].size(); i++) {       if (v[x][i] == y) continue;       if (fix[v[x][i]] == 1) continue;       fix[v[x][i]] = 1;       swap(A[B[root]], A[B[v[x][i]]]);       ans += 2;       a = B[root];       B[root] = B[v[x][i]];       B[v[x][i]] = a;       root = v[x][i];     }   }   int main() {     cin >> n;     for (long long i = 1; i <= n; i++) {       A[i] = i;       B[i] = i;     }     for (long long i = 1; i < n; i++) {       cin >> a >> b;       v[a].push_back(b);       v[b].push_back(a);     }     dfs(1, 0);     if (fix[1] == 0) {       a = v[1][0];       swap(A[1], A[B[v[1][0]]]);       ans += 2;     }     cout << ans << endl;     for (long long i = 1; i <= n; i++) cout << A[i] <<    ;   }   