#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5;
vector<int> g[maxn];
bool vis[maxn];
map<int, map<int, int> > mp;
int c[maxn], tmp[maxn], d[maxn];
int num = 0;
bool dfs(int v, int col, int k, int kk) {
  vis[v] = 1;
  if (d[v] > kk) {
    ++num;
    if (num > k) {
      return false;
    }
    if (!col) {
      col = 1;
    }
    for (auto i : g[v]) {
      if (!vis[i]) {
        tmp[mp[v][i]] = col;
      }
    }
  } else {
    int cc = 1;
    for (auto i : g[v]) {
      if (!vis[i]) {
        if (cc == col) {
          ++cc;
        }
        tmp[mp[v][i]] = cc;
        ++cc;
      }
    }
  }
  for (auto i : g[v]) {
    if (!vis[i]) {
      if (!dfs(i, tmp[mp[v][i]], k, kk)) {
        return false;
      }
    }
  }
  return true;
}
bool check(int k, int kk) {
  memset(vis, 0, sizeof vis);
  num = 0;
  return dfs(1, 0, k, kk);
}
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    mp[x][y] = i;
    mp[y][x] = i;
    g[x].push_back(y);
    g[y].push_back(x);
    ++d[x], ++d[y];
  }
  vector<int> v;
  for (int i = 1; i <= n; ++i) {
    v.push_back(d[i]);
  }
  sort(v.begin(), v.end());
  int l = 1, r = n - 1;
  int ans = 1;
  c[1] = 1;
  for (int mid = 1;; ++mid) {
    int t = upper_bound(v.begin(), v.end(), mid) - v.begin();
    if (n - t <= k && check(k, mid)) {
      ans = mid;
      for (int i = 1; i <= n; ++i) c[i] = tmp[i];
      break;
    }
  }
  cout << ans << endl;
  for (int i = 1; i < n; ++i) {
    cout << c[i] << " ";
  }
  cout << endl;
  return 0;
}
