#include <bits/stdc++.h>
using namespace std;
int n, k;
vector<pair<int, int> > g[2 * 100002];
vector<int> d;
int mass[2 * 100002];
int color[2 * 100002];
int qan;
void dfs(int v = 1, int p = -1, int col = 1) {
  for (auto x : g[v]) {
    if (x.first == p) continue;
    if (col > qan) col = 1;
    color[x.second] = col++;
    dfs(x.first, v, col);
  }
}
int main() {
  cin >> n >> k;
  for (int(i) = 0; (i) < (n - 1); (i)++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(make_pair(y, i));
    g[y].push_back(make_pair(x, i));
    mass[x]++;
    mass[y]++;
  }
  sort(mass + 1, mass + n + 1, greater<int>());
  qan = mass[k + 1];
  cout << qan << endl;
  dfs();
  for (int(i) = 0; (i) < (n - 1); (i)++) cout << color[i] << " ";
  return 0;
}
