#include <bits/stdc++.h>
using namespace std;
long long int vmax(vector<long long int> v) {
  long long int max = v[0];
  long long int j;
  for (j = 0; j < v.size(); j++) {
    if (v[j] > max) {
      max = v[j];
    }
  }
  return (max);
}
long long int vmin(vector<long long int> v) {
  long long int min = v[0];
  long long int j;
  for (j = 0; j < v.size(); j++) {
    if (v[j] < min) {
      min = v[j];
    }
  }
  return (min);
}
long long int n;
vector<long long int> v[200000 + 5];
long long int visited[200000 + 5];
long long int colors[200000 + 5];
void dfs(long long int root, long long int color_root,
         long long int color_parent, long long int max_colors) {
  long long int i = 1;
  for (int j = 0; j < v[root].size(); j += 1) {
    if (!visited[v[root][j]]) {
      if (i == color_root || i == color_parent) {
        i++;
      }
      if (i == color_root || i == color_parent) {
        i++;
      }
      visited[v[root][j]] = 1;
      colors[v[root][j]] = i;
      dfs(v[root][j], colors[v[root][j]], color_root, max_colors);
      i++;
    }
  }
}
void solve() {
  cin >> n;
  memset(visited, 0, sizeof(visited));
  memset(colors, -1, sizeof(colors));
  for (int j = 0; j < n - 1; j += 1) {
    long long int x, y;
    cin >> x >> y;
    x--;
    y--;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  long long int max_colors = v[0].size();
  long long int that_vertex = 0;
  for (int j = 0; j < n; j += 1) {
    if (v[j].size() > max_colors) {
      max_colors = v[j].size();
      that_vertex = j;
    }
  }
  max_colors++;
  colors[that_vertex] = max_colors;
  visited[that_vertex] = 1;
  for (int j = 0; j < v[that_vertex].size(); j += 1) {
    colors[v[that_vertex][j]] = max_colors - 1 - j;
    visited[v[that_vertex][j]] = 1;
  }
  for (int j = 0; j < v[that_vertex].size(); j += 1) {
    dfs(v[that_vertex][j], colors[v[that_vertex][j]], colors[that_vertex],
        max_colors);
  }
  cout << max_colors << "\n";
  for (int j = 0; j < n; j += 1) {
    cout << colors[j] << " ";
  }
  cout << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t = 1;
  while (t--) {
    solve();
  }
}
