#include <bits/stdc++.h>
using i64 = long long;
std::vector<std::deque<std::pair<int, int>>> g;
std::vector<int> c;
int mod;
void dfs(int v, int p, int nc) {
  for (auto &el : g[v]) {
    if (el.first == p) continue;
    c[el.second] = (nc++) % mod;
    dfs(el.first, v, nc % mod);
  }
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  g.resize(n);
  c.resize(n - 1);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    g[u].emplace_back(v, i);
    g[v].emplace_back(u, i);
  }
  std::vector<int> deg(n + 1);
  for (int i = 0; i < n; i++) deg[g[i].size()]++;
  for (int i = n; i > 0; i--) deg[i - 1] += deg[i];
  int l = 0, r = n;
  while (r - l > 1) {
    int m = (l + r) / 2;
    if (k < deg[m + 1])
      l = m;
    else
      r = m;
  }
  mod = r;
  dfs(0, -1, 0);
  printf("%d\n", r);
  for (const auto el : c) printf("%d ", el + 1);
  printf("\n");
  return 0;
}
