#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, k, cntedge = 1;
vector<int> G[N], id[N];
int ans[N], lmt, deg[N];
void addedge(int u, int v) {
  G[u].push_back(v);
  id[u].push_back(++cntedge);
  ++deg[u];
}
void dfs(int u, int pa, int col) {
  int us = 0;
  for (int v, ii, i = 0; i < (int)G[u].size(); i++) {
    v = G[u][i];
    ii = id[u][i];
    if (v == pa) {
      continue;
    }
    ++us;
    if (us == col) {
      ++us;
    }
    if (us <= lmt) {
      ans[ii >> 1] = us;
      dfs(v, u, us);
    } else {
      ans[ii >> 1] = col ? col : 1;
      dfs(v, u, col ? col : 1);
    }
  }
}
bool cmp(int u, int v) { return u > v; }
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    addedge(u, v);
    addedge(v, u);
  }
  sort(deg + 1, deg + n + 1, cmp);
  lmt = deg[k + 1];
  dfs(1, 0, 0);
  printf("%d\n", lmt);
  for (int i = 1; i < n; i++) {
    printf("%d ", ans[i]);
  }
  return 0;
}
