#include <bits/stdc++.h>
using namespace std;
const int maxn = 200005;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double pi = acos(-1);
vector<int> mp[maxn];
int cntE[maxn];
map<pair<int, int>, int> id;
int clr[maxn];
bool vis[maxn];
int ans;
void add(int &k) {
  if (k < ans) k++;
}
void dfs(int u, int used) {
  vis[u] = true;
  int k = 1;
  if (used == 1) add(k);
  for (int v : mp[u]) {
    if (vis[v]) continue;
    int i = id[make_pair(u, v)];
    clr[i] = k;
    dfs(v, k);
    add(k);
    if (k == used) add(k);
  }
}
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    mp[u].push_back(v);
    mp[v].push_back(u);
    pair<int, int> p = make_pair(u, v);
    pair<int, int> rp = make_pair(v, u);
    id[p] = id[rp] = i;
  }
  for (int i = 1; i <= n; i++) {
    cntE[i] = mp[i].size();
  }
  sort(cntE + 1, cntE + 1 + n);
  ans = cntE[n - k];
  dfs(1, 0);
  printf("%d\n", ans);
  for (int i = 1; i < n; i++) {
    printf("%d%c", clr[i], i == n - 1 ? '\n' : ' ');
  }
  return 0;
}
