#include <bits/stdc++.h>
using namespace std;
struct debugger {
  template <typename T>
  debugger& operator,(const T& x) {
    clog << x << " ";
    return *this;
  }
} dbg;
auto ____ = []() {
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();
int main(int argc, char* argv[]) {
  int n, K;
  cin >> n >> K;
  vector<pair<int, int> > edges(n - 1);
  vector<vector<pair<int, int> > > g(n);
  for (int i = 0; i < (n - 1); ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    edges[i].first = x, edges[i].second = y;
    g[x].push_back(make_pair(y, i));
    g[y].push_back(make_pair(x, i));
  }
  vector<pair<int, int> > deg(n);
  for (int i = 0; i < (n); ++i) deg[i] = make_pair((int)(g[i]).size(), i);
  sort(deg.begin(), deg.end(), greater<pair<int, int> >());
  int R = deg[K].first;
  vector<int> edge_color(n - 1, -1);
  stack<pair<int, int> > S;
  S.push(make_pair(0, -1));
  while (!S.empty()) {
    auto p = S.top();
    S.pop();
    int x = p.first, c = p.second;
    int d = 0;
    for (auto y : g[x]) {
      d %= R;
      if (edge_color[y.second] == -1) {
        if (R == 1)
          d = 0;
        else if (d == c) {
          d++;
          d %= R;
        }
        edge_color[y.second] = d;
        S.push(make_pair(y.first, d));
        ++d;
      }
    }
  }
  cout << R << '\n';
  for (auto c : edge_color) {
    cout << c + 1 << ' ';
  }
  cout << '\n';
  return 0;
}
