#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<pair<int, int> > adj[N];
vector<int> okfine;
int ans[N], num;
void dfs(int x, int p, int col) {
  int now = 1;
  bool cac = true;
  for (int i = 0; i < adj[x].size(); i++) {
    if (adj[x][i].first != p) {
      if (now == col) {
        if (cac) {
          now++;
          if (now > okfine[okfine.size() - 1 - num]) {
            now -= okfine[okfine.size() - 1 - num];
          }
          cac = false;
        }
      }
      ans[adj[x][i].second] = now;
      dfs(adj[x][i].first, x, now);
      now++;
      if (now > okfine[okfine.size() - 1 - num]) {
        now -= okfine[okfine.size() - 1 - num];
      }
    }
  }
}
int main() {
  int n, i, j, k, l;
  cin >> n >> num;
  for (i = 1; i < n; i++) {
    cin >> j >> k;
    adj[j].push_back({k, i});
    adj[k].push_back({j, i});
  }
  for (i = 1; i <= n; i++) {
    okfine.push_back(adj[i].size());
  }
  sort(okfine.begin(), okfine.end());
  dfs(1, 1, 0);
  cout << okfine[n - num - 1] << endl;
  for (i = 1; i < n; i++) {
    cout << ans[i] << " ";
  }
}
