#include <bits/stdc++.h>
using namespace std;
int n, k, x, y, ans, deg[200200], col[200200];
vector<int> graph[200200];
map<pair<int, int>, int> ind;
void dfs(int u, int p, int lc) {
  int ng = graph[u].size();
  if (ng > ans) {
    for (int v : graph[u])
      if (v != p) {
        col[ind[pair<int, int>(min(u, v), max(u, v))]] = 1;
        dfs(v, u, 1);
      }
  } else {
    int atual = 1;
    for (int v : graph[u])
      if (v != p) {
        if (atual == lc) atual++;
        col[ind[pair<int, int>(min(u, v), max(u, v))]] = atual;
        dfs(v, u, atual);
        atual++;
      }
  }
}
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", &x, &y);
    graph[x].push_back(y);
    graph[y].push_back(x);
    deg[x - 1]++;
    deg[y - 1]++;
    ind[pair<int, int>(min(x, y), max(x, y))] = i;
  }
  sort(deg, deg + n);
  int p = 0;
  for (int i = 1; i < n; i++) {
    while (p < n && deg[p] == i) p++;
    if (n - p <= k) {
      ans = i;
      break;
    }
  }
  printf("%d\n", ans);
  dfs(1, 0, -1);
  for (int i = 0; i < n - 1; i++) {
    if (i) printf(" ");
    printf("%d", col[i]);
  }
  printf("\n");
  return 0;
}
