#include <bits/stdc++.h>
using namespace std;
vector<pair<int64_t, int64_t> > w;
vector<vector<int64_t> > d;
bool con(int64_t t, set<int64_t> &st) { return (st.find(t) != st.end()); }
int64_t get_o(int64_t e, int64_t t) {
  if (w[e].first == t) return w[e].second;
  return w[e].first;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  int64_t n, k;
  cin >> n >> k;
  d.resize(n);
  for (int64_t i = 0; i < n - 1; ++i) {
    int64_t a, b;
    cin >> a >> b;
    --a;
    --b;
    d[a].push_back(w.size());
    d[b].push_back(w.size());
    w.push_back({a, b});
  }
  vector<pair<int64_t, int64_t> > u(n);
  for (int64_t i = 0; i < n; ++i) u[i] = {d[i].size(), i};
  sort(u.begin(), u.end());
  vector<char> ch(n + 3, false);
  vector<int64_t> ans(n);
  vector<set<int64_t> > st(n);
  vector<char> L(n, false), K(n, false);
  for (int64_t q = n - k - 1; q >= 0; --q) {
    L[u[q].second] = true;
    K[u[q].second] = true;
  }
  for (int64_t q = n - k - 1; q >= 0; --q) {
    int64_t h = u[q].second;
    if (!K[h]) continue;
    queue<int64_t> Q;
    Q.push(h);
    K[h] = false;
    while (Q.size()) {
      int64_t t = Q.front();
      Q.pop();
      int64_t tec = 1;
      for (int64_t i = 0; i < d[t].size(); ++i) {
        int64_t e = d[t][i];
        if (ans[e]) continue;
        int64_t o = get_o(e, t);
        while (con(tec, st[t]) || con(tec, st[o])) ++tec;
        ans[e] = tec;
        st[t].insert(tec);
        if (L[o]) st[o].insert(tec);
        if (K[o]) {
          Q.push(o);
          K[o] = false;
        }
      }
    }
  }
  int64_t mx = 1;
  for (int64_t i = 0; i < n; ++i)
    if (ans[i] > mx) mx = ans[i];
  cout << mx << endl;
  for (int64_t i = 0; i < n - 1; ++i)
    if (!ans[i])
      cout << "1 ";
    else
      cout << ans[i] << ' ';
}
