#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 100 * 1000 + 20;
int n, k, v[N], u[N], col[N], ans, d[N];
vector<pair<int, int> > adj[N];
void dfs(int v, int x, int par = -1, int colPrv = -1) {
  int c = 1;
  for (auto u : adj[v]) {
    if (c != x && c == colPrv) c++;
    if (u.first ^ par) {
      col[u.second] = c;
      dfs(u.first, x, v, c);
      if (c != x) c++;
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i < n; i++) {
    cin >> v[i] >> u[i];
    adj[--v[i]].push_back(pair<int, int>(--u[i], i));
    adj[u[i]].push_back(pair<int, int>(v[i], i));
    d[v[i]]++;
    d[u[i]]++;
  }
  sort(d, d + n, greater<int>());
  ans = d[k];
  dfs(0, ans);
  cout << ans << "\n";
  for (int i = 1; i < n; i++) cout << col[i] << " ";
  return cout << endl, 0;
}
