#include <bits/stdc++.h>
using namespace std;
const long long BIG = 1000000000000000000LL;
void cpr(string s, vector<long long> v) {
  long long i = 0;
  for (char c : s) {
    if (c == '$')
      cout << v[i++];
    else
      cout << c;
  }
  cout << '\n';
}
void cpr(string s) { cpr(s, {}); }
void solve();
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
long long nbNoeuds, maxErr;
const long long borne = 201 * 1000 + 5;
long long col[borne];
vector<pair<long long, long long> > adj[borne];
pair<long long, long long> deg[borne];
long long sol;
bool vu[borne];
stack<long long> dc[borne];
void dfs(long long nod, long long deny) {
  vu[nod] = true;
  long long curCol = 0;
  for (auto x : adj[nod]) {
    long long vo = x.first, li = x.second;
    if (vu[vo]) continue;
    if (curCol == deny) ++curCol;
    curCol %= sol;
    col[li] = curCol++;
    curCol %= sol;
    dfs(vo, col[li]);
  }
}
void solve() {
  cin >> nbNoeuds >> maxErr;
  for (long long i = (0); i < (nbNoeuds); ++i) deg[i].second = i;
  for (long long i = (0); i < (nbNoeuds - 1); ++i) {
    long long u, v;
    cin >> u >> v;
    --u;
    --v;
    adj[u].push_back({v, i});
    adj[v].push_back({u, i});
    ++deg[u].first;
    ++deg[v].first;
  }
  sort(deg, deg + nbNoeuds);
  sol = deg[nbNoeuds - 1 - maxErr].first;
  cout << sol << "\n";
  dfs(deg[0].second, -1);
  for (long long i = (0); i < (nbNoeuds - 1); ++i) cout << col[i] + 1 << " ";
  cout << "\n";
}
