#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, k, ans;
vector<pair<int, int> > e[maxn];
vector<int> num;
int a[maxn];
void dfs(int x, int y, int z) {
  int cnt = 0;
  for (auto i : e[x]) {
    if (i.first == y) continue;
    cnt++;
    if (cnt == z) cnt++;
    if (cnt > ans) cnt -= ans;
    a[i.second] = cnt;
    dfs(i.first, x, cnt);
  }
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    cin >> x >> y;
    e[x].push_back({y, i});
    e[y].push_back({x, i});
  }
  for (int i = 1; i <= n; i++) num.push_back(e[i].size());
  sort(num.begin(), num.end());
  ans = num[n - k - 1];
  cout << ans << endl;
  dfs(1, 0, 0);
  for (int i = 1; i <= n - 1; i++) {
    cout << a[i];
    if (i != n) cout << ' ';
  }
  cout << endl;
  return 0;
}
