#include <bits/stdc++.h>
using namespace std;
int n, k, u, v, in[200005], c[200005], m, i;
struct node {
  int e, v;
};
vector<node> g[200005];
bool cmp(int x, int y) { return x > y; }
void dfs(int u, int fa, int cl) {
  for (int i = 0; i < g[u].size(); i++) {
    int v = g[u][i].v, id = g[u][i].e;
    if (v == fa) continue;
    if (cl > m) cl -= m;
    c[id] = cl++;
    dfs(v, u, cl);
  }
}
int main() {
  cin >> n >> k;
  for (i = 1; i <= n - 1; i++) {
    scanf("%d%d", &u, &v);
    in[u]++;
    in[v]++;
    g[u].push_back({i, v});
    g[v].push_back({i, u});
  }
  sort(in + 1, in + n + 1, cmp);
  m = in[k + 1];
  dfs(1, 0, 1);
  printf("%d\n", m);
  for (i = 1; i <= n - 1; i++) {
    printf("%d ", c[i]);
  }
}
