#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
const int N = 2e5 + 5;
const long long int mod = 1e9 + 7;
const long long int Mod = 998244353;
const long double Pi = acos(-1);
const long long int Inf = 4e18;
using namespace std;
vector<int> g[N], ans(N), deg(N, 0), f(N, 0);
map<pair<int, int>, int> l;
void Dfs(int t, int p, int r) {
  if (deg[t] > r) {
    if (p == -1) {
      for (auto u : g[t]) ans[l[{t, u}]] = 1;
    } else {
      for (auto u : g[t]) {
        if (u != p) {
          ans[l[{u, t}]] = ans[l[{t, p}]];
        }
      }
    }
  } else {
    int mex = 1;
    if (p != -1) {
      mex = (ans[l[{t, p}]] == 1 ? 2 : 1);
    }
    for (auto u : g[t]) {
      if (u != p) {
        ans[l[{u, t}]] = mex;
        mex++;
        if (mex == ans[l[{t, p}]]) mex++;
      }
    }
  }
  for (auto u : g[t]) {
    if (u != p) Dfs(u, t, r);
  }
}
void TestCase() {
  int n, k, sum = 0, r = 1;
  cin >> n >> k;
  for (int i = 1, u, v; i < n; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
    deg[u]++;
    deg[v]++;
    l[{u, v}] = l[{v, u}] = i;
  }
  for (int i = 1; i <= n; i++) f[deg[i]]++;
  int mx = *max_element(deg.begin() + 1, deg.begin() + n + 1);
  for (int i = mx; i >= 2; i--) {
    if (sum + f[i] > k) {
      r = i;
      break;
    } else
      sum += f[i];
  }
  Dfs(1, -1, r);
  cout << r << "\n";
  for (int i = 1; i < n; i++) cout << ans[i] << " ";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  int T = 1;
  while (T--) {
    TestCase();
    cout << "\n";
  }
  return 0;
}
