#include <bits/stdc++.h>
using namespace std;
int r;
vector<int> col;
void dfs(vector<pair<int, int> > adj[], int node, int p, int f) {
  int colour = 0;
  for (int i = 0; i < adj[node].size(); i++) {
    pair<int, int> g = adj[node][i];
    if (p != g.first) {
      if (colour == f) {
        colour = (colour + 1) % r;
        f = -1;
      }
      col[g.second] = colour;
      dfs(adj, g.first, node, colour);
      colour = (colour + 1) % r;
    }
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > adj[n + 1];
  int x, y;
  vector<int> p(n + 1, 0);
  int mx = INT_MIN;
  pair<int, int> p1[n];
  for (int i = 0; i < n - 1; i++) {
    cin >> x >> y;
    adj[x].push_back(make_pair(y, i));
    adj[y].push_back(make_pair(x, i));
    p[x]++;
    p[y]++;
  }
  for (int i = 0; i < n; i++) {
    p1[i].first = p[i + 1];
    p1[i].second = i + 1;
  }
  sort(p1, p1 + n, greater<pair<int, int> >());
  r = p1[k].first;
  col.resize(n - 1);
  cout << r << endl;
  dfs(adj, 1, -1, -1);
  for (int i = 0; i < n - 1; i++) {
    cout << col[i] + 1 << " ";
  }
  cout << endl;
}
