#include <bits/stdc++.h>
using namespace std;
inline pair<int, int> get_ordered_pair(int u, int v) {
  return u > v ? make_pair(v, u) : make_pair(u, v);
}
int main(void) {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int>> edges(n + 1);
  map<pair<int, int>, int> edge2co;
  vector<pair<int, int>> degrees(n + 1);
  vector<bool> nogood(n + 1, false);
  vector<vector<int>> g(n + 1);
  for (int i = 1; i <= n; i++) {
    degrees[i] = {0, i};
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    if (u > v) {
      swap(u, v);
    }
    g[u].push_back(v);
    g[v].push_back(u);
    edges[i] = {u, v};
    degrees[u].first++;
    degrees[v].first++;
  }
  sort(degrees.begin() + 1, degrees.end());
  for (int i = 0; i < k; i++) {
    nogood[degrees[n - i].second] = true;
  }
  int r = degrees[n - k].first;
  queue<pair<int, int>> q;
  q.push({1, 0});
  while (!q.empty()) {
    int u = q.front().first;
    int par_co = q.front().second;
    q.pop();
    if (u == 1) {
      for (int i = 0; i < g[u].size(); i++) {
        int v = g[u][i];
        pair<int, int> ordered_pair = get_ordered_pair(u, v);
        edge2co[ordered_pair] = nogood[u] ? 1 : i + 1;
        q.push({v, edge2co[ordered_pair]});
      }
    } else {
      for (int i = 0, idx = 0; i < g[u].size(); i++) {
        int v = g[u][i];
        pair<int, int> ordered_pair = get_ordered_pair(u, v);
        if (edge2co[ordered_pair] == 0) {
          if (!nogood[u])
            while (++idx == par_co)
              ;
          edge2co[ordered_pair] = nogood[u] ? par_co : idx;
          q.push({v, edge2co[ordered_pair]});
        }
      }
    }
  }
  cout << r << endl;
  for (int i = 1; i < n; i++) {
    cout << edge2co[edges[i]] << " ";
  }
  cout << endl;
  return 0;
}
