#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 200010;
vector<pair<int, int> > graph[maxn];
int degree[maxn];
map<int, int> deg_cnt;
int chosen_deg = 0;
int col[maxn];
void dfs(int node, int origin, int in_col) {
  int color = 0;
  for (auto edge : graph[node]) {
    if (edge.first == origin) continue;
    if (color == in_col) {
      (++color) %= chosen_deg;
      in_col = -1;
    }
    col[edge.second] = color;
    dfs(edge.first, node, color);
    (++color) %= chosen_deg;
  }
}
int main() {
  int n, k;
  cin >> n >> k;
  for (long long i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    graph[u].push_back(make_pair(v, i));
    graph[v].push_back(make_pair(u, i));
    degree[u]++;
    degree[v]++;
  }
  for (long long i = 0; i < n; i++) {
    deg_cnt[degree[i]]++;
  }
  int valid = n;
  for (auto i : deg_cnt) {
    if (valid > k) {
      chosen_deg = i.first;
      valid -= i.second;
    } else
      break;
  }
  dfs(0, -1, -1);
  cout << chosen_deg << endl;
  for (long long i = 0; i < n - 1; i++) {
    cout << col[i] + 1;
    if (i < n - 2)
      cout << " ";
    else
      cout << endl;
  }
  return 0;
}
