#include <bits/stdc++.h>
using namespace std;
int n, k;
set<pair<int, int> > yo;
vector<pair<int, int> > edges;
map<pair<int, int>, int> ans, aux;
vector<int> graph[200010];
int check;
void dfs(int node, int p, int r) {
  int nope = 0;
  if (aux.count(make_pair(node, p)))
    nope = aux[make_pair(node, p)];
  else if (aux.count(make_pair(p, node)))
    nope = aux[make_pair(p, node)];
  int options = r, sz = graph[node].size();
  if (nope != 0) options--, sz--;
  if (sz <= options) {
    int cnt = 1;
    for (int nb : graph[node]) {
      if (p != nb) {
        if (cnt == nope) cnt++;
        if (yo.count(make_pair(node, nb)))
          aux[make_pair(node, nb)] = cnt;
        else if (yo.count(make_pair(nb, node)))
          aux[make_pair(nb, node)] = cnt;
        dfs(nb, node, r);
        cnt++;
      }
    }
  } else {
    check++;
    if (nope == 0) nope = 1;
    for (int nb : graph[node]) {
      if (p != nb) {
        if (yo.count(make_pair(node, nb)))
          aux[make_pair(node, nb)] = nope;
        else if (yo.count(make_pair(nb, node)))
          aux[make_pair(nb, node)] = nope;
        dfs(nb, node, r);
      }
    }
  }
}
bool solve(int r, bool flag) {
  check = 0;
  dfs(1, -1, r);
  if (check <= k) {
    if (flag) ans = aux;
    return true;
  }
  return false;
}
int main() {
  int n1, n2, l, r, m;
  scanf("%d %d", &n, &k);
  ;
  vector<int> deg;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d %d", &n1, &n2);
    ;
    graph[n1].emplace_back(n2);
    graph[n2].emplace_back(n1);
    edges.emplace_back(make_pair(n1, n2));
    yo.insert(make_pair(n1, n2));
  }
  for (int i = 1; i <= n; i++) deg.emplace_back(graph[i].size());
  sort(deg.begin(), deg.end());
  int vv = deg[n - 1 - k];
  solve(vv, true);
  printf("%d\n", vv);
  for (int i = 0; i < n - 1; i++) {
    if (i != 0) printf(" ");
    printf("%d", ans[edges[i]]);
  }
  printf("\n");
  return 0;
}
