#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
vector<pair<int, int> > g[N];
int n, k, ans, a[N], big[N], vis[N], col[N], prin[N];
bool cmp(int x, int y) { return g[x].size() > g[y].size(); }
void bfs() {
  queue<int> q;
  q.push(1);
  vis[1] = 1;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    int c = 1;
    for (auto v : g[u]) {
      if (!vis[v.first]) {
        if (big[u]) {
          col[v.first] = prin[v.second] = 1;
        } else {
          if (col[u] == c) c++;
          col[v.first] = prin[v.second] = c;
          ans = max(ans, c);
          c++;
        }
        vis[v.first] = 1;
        q.push(v.first);
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back({v, i});
    g[v].push_back({u, i});
  }
  for (int i = 1; i <= n; i++) {
    a[i] = i;
  }
  sort(a + 1, a + n + 1, cmp);
  ans = 1;
  for (int i = 1; i <= min(n, k); i++) {
    big[a[i]] = 1;
  }
  bfs();
  cout << ans << '\n';
  for (int i = 1; i < n; i++) {
    cout << prin[i] << " ";
  }
  return 0;
}
