#include <bits/stdc++.h>
using namespace std;
long long maxi = LLONG_MIN;
long long mini = LLONG_MAX;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long t, i, j, k, n, temp, flag, m;
vector<pair<int, int> > a[200005];
vector<long long> pa(200005, 0), ans(200005, 0), mark(200005, 0), v(200005, 0);
int root = 1;
void dfs(int u) {
  if (mark[u] == 1) {
    v[u] = 1;
    for (auto i : a[u]) {
      int ele = i.first;
      if (!v[ele]) {
        if (u != root)
          ans[i.second] = ans[pa[u]];
        else
          ans[i.second] = 1;
        pa[ele] = i.second;
        dfs(ele);
      }
    }
  } else {
    v[u] = 1;
    int x = 1;
    for (auto i : a[u]) {
      int ele = i.first;
      if (!v[ele]) {
        if (x == ans[pa[u]]) x++;
        ans[i.second] = x;
        pa[ele] = i.second;
        x++;
        dfs(ele);
      }
    }
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    a[u].push_back(make_pair(v, i));
    a[v].push_back(make_pair(u, i));
  }
  vector<pair<int, int> > sz;
  for (int i = 1; i <= n; i++) {
    sz.push_back(make_pair(a[i].size(), i));
  }
  sort(sz.rbegin(), sz.rend());
  root = sz[0].second;
  for (int i = 0; i < k; i++) {
    mark[sz[i].second] = 1;
  }
  dfs(root);
  long long ans1 = 0;
  for (int i = 1; i < n; i++) {
    ans1 = max(ans1, ans[i]);
  }
  cout << ans1 << "\n";
  for (int i = 1; i < n; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}
