#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 100;
vector<int> g[maxn];
struct point {
  int u, v;
  point(int a = 0, int b = 0) : u(a), v(b) {}
};
bool operator<(const point& a, const point& b) {
  if (a.u == b.u) return a.v < b.v;
  return a.u < b.u;
}
point p[maxn];
int d[maxn], n, k;
int m;
map<point, int> mm;
void dfs(int i, int fa, int x) {
  int num = g[i].size();
  int v;
  int cnt = 1;
  for (int j = 0; j < num; j++) {
    v = g[i][j];
    if (v == fa) continue;
    if (cnt == x) cnt++;
    if (num <= m) {
      mm[point(min(v, i), max(v, i))] = cnt;
      dfs(v, i, cnt);
    } else {
      mm[point(min(v, i), max(v, i))] = 1;
      dfs(v, i, 1);
    }
    ++cnt;
  }
}
int main() {
  cin >> n >> k;
  int a, b;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    if (a > b) swap(a, b);
    g[a].push_back(b);
    g[b].push_back(a);
    d[a]--;
    d[b]--;
    p[i].u = a;
    p[i].v = b;
  }
  sort(d, d + n);
  m = -d[k];
  m = max(m, 1);
  int num = g[1].size(), v;
  for (int i = 0; i < num; i++) {
    v = g[1][i];
    if (num <= m) {
      mm[point(min(v, 1), max(v, 1))] = i + 1;
      dfs(v, 1, i + 1);
    } else {
      mm[point(min(v, 1), max(v, 1))] = 1;
      dfs(v, 1, 1);
    }
  }
  cout << m << endl;
  for (int i = 1; i < n; i++) cout << mm[p[i]] << ' ';
  return 0;
}
