#include <bits/stdc++.h>
using namespace std;
struct node {
  int v, fr, num;
} e[200010 << 1], angle[200010];
int n, K, tail[200010], cnt = 0, ans, color_[200010];
inline int read() {
  int x = 0, f = 0;
  char c = getchar();
  while (c < '0' || c > '9') f = (c == '-') ? 1 : f, c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
  return f ? -x : x;
}
inline void add(int u, int v, int num) {
  e[++cnt] = (node){v, tail[u], num};
  tail[u] = cnt;
}
inline bool cmp(node x, node y) { return x.v > y.v; }
inline bool rec(node x, node y) { return x.fr < y.fr; }
void dfs(int x, int fa, int col) {
  int now = 1;
  for (int p = tail[x], v; p; p = e[p].fr) {
    if ((v = e[p].v) == fa) continue;
    if (now == col) now = now % ans + 1;
    color_[e[p].num] = now, dfs(v, x, now);
    now = now % ans + 1;
  }
}
int main() {
  n = read(), K = read();
  for (int i = (1); i <= (n); i++) angle[i].fr = i;
  for (int i = (2); i <= (n); i++) {
    int u = read(), v = read();
    angle[u].v++, angle[v].v++;
    add(u, v, i - 1), add(v, u, i - 1);
  }
  sort(angle + 1, angle + n + 1, cmp);
  ans = angle[K + 1].v;
  int st = 0;
  printf("%d\n", ans);
  sort(angle + 1, angle + n + 1, rec);
  for (int i = (1); i <= (n); i++)
    if (angle[i].v > angle[st].v) st = i;
  dfs(st, 0, 0);
  for (int i = (1); i <= (n - 1); i++) printf("%d ", color_[i]);
  printf("\n");
  return 0;
}
