#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 korupcija(long long int x, long long int c, long long int otac) {
  for (int i = 0; i < vek[x].size(); i++) {
    if (vek[x][i] == otac) continue;
    c++;
    c %= t;
    mapi[{vek[x][i], x}] = c;
    mapi[{x, vek[x][i]}] = c;
    korupcija(vek[x][i], c, x);
  }
}
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();
  korupcija(A, 0, A);
  cout << t << endl;
  for (int i = 0; i < n - 1; i++) {
    cout << mapi[par[i]] + 1 << " ";
  }
  return 0;
}
