#include <bits/stdc++.h>
#pragma GCC optimise("Ofast,unroll-loops,no-stack-protector,fast-math");
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")
using namespace std;
int n, r;
vector<vector<pair<int, int>>> graph;
vector<int> color;
vector<bool> was;
int ans;
void dfs(int v, int c = -1) {
  was[v] = true;
  int j = 1;
  vector<pair<int, int>> kek;
  for (auto &i : graph[v]) {
    if (!color[i.second]) {
      if (c != -1 && j == c) {
        j++;
      }
      kek.push_back({i.first, j});
      color[i.second] = j++;
    }
  }
  for (auto &i : kek) {
    if (!was[i.first]) {
      dfs(i.first, i.second);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> r;
  graph.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    graph[a].push_back({b, i});
    graph[b].push_back({a, i});
  }
  vector<pair<int, int>> order;
  for (int i = 0; i < n; i++) {
    order.push_back({graph[i].size(), i});
  }
  sort(order.begin(), order.end(), greater<pair<int, int>>());
  ans = graph[order[r].second].size();
  was.resize(n);
  for (int i = 0; i < r; i++) {
    was[order[i].second] = true;
  }
  color.resize(n - 1);
  for (int i = 0; i < n; i++) {
    if (!was[i]) {
      dfs(i);
    }
  }
  cout << ans << '\n';
  for (auto &i : color) {
    if (!i) {
      i = 1;
    }
    cout << i << " ";
  }
  return 0;
}
