#include <bits/stdc++.h>
using namespace std;
const long long int maxn = 2e5 + 10;
long long int n, k, t, A;
priority_queue<long long int> q;
queue<pair<long long int, long long int> > kju;
vector<long long int> vek[maxn];
map<pair<long long int, long long int>, long long int> mapi;
pair<long long int, long long int> par[maxn];
bool bio[maxn];
void adiraj() {
  while (!kju.empty()) {
    long long int x = kju.front().second;
    long long int r = kju.front().first;
    kju.pop();
    for (int i = 0; i < vek[r].size(); i++) {
      if (!bio[vek[r][i]]) {
        mapi[{vek[r][i], r}] = x;
        mapi[{r, vek[r][i]}] = x;
        x++;
        x %= t;
        kju.push({vek[r][i], x});
        bio[vek[r][i]] = 1;
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0; i < n - 1; i++) {
    long long int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (!i) A = a;
    vek[a].push_back(b);
    vek[b].push_back(a);
    par[i].first = a;
    par[i].second = b;
  }
  for (int i = 0; i < n - 1; i++) {
    q.push(vek[i].size());
  }
  while (k) {
    q.pop();
    k--;
  }
  t = q.top();
  bio[A] = 1;
  kju.push({A, 0});
  adiraj();
  cout << t << endl;
  for (int i = 0; i < n - 1; i++) {
    cout << mapi[par[i]] + 1 << " ";
  }
  return 0;
}
