#include <bits/stdc++.h>
using namespace std;
long long int INF = 1e9 + 5;
long long int mod = 998244353;
long long int n, k;
vector<long long int> ans, deg;
vector<vector<pair<long long int, long long int>>> g;
void _print(long long int t) { cerr << t; }
void _print(int t) { cerr << t; }
void _print(string t) { cerr << t; }
void _print(char t) { cerr << t; }
void _print(long double t) { cerr << t; }
void _print(double t) { cerr << t; }
void _print(unsigned long long t) { cerr << t; }
template <class T, class V>
void _print(pair<T, V> p);
template <class T>
void _print(vector<T> v);
template <class T>
void _print(set<T> v);
template <class T, class V>
void _print(map<T, V> v);
template <class T>
void _print(multiset<T> v);
template <class T, class V>
void _print(pair<T, V> p) {
  cerr << "{";
  _print(p.f);
  cerr << ",";
  _print(p.s);
  cerr << "}";
}
template <class T>
void _print(vector<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(set<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T>
void _print(multiset<T> v) {
  cerr << "[ ";
  for (T i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
template <class T, class V>
void _print(map<T, V> v) {
  cerr << "[ ";
  for (auto i : v) {
    _print(i);
    cerr << " ";
  }
  cerr << "]";
}
void dfs(long long int node, long long int pa, long long int used,
         long long int col) {
  long long int curr = 1;
  for (auto &child : g[node]) {
    if (child.first == pa) {
      continue;
    }
    if (curr == used) {
      curr++;
    }
    if (curr > col) {
      curr--;
    }
    ans[child.second] = curr;
    dfs(child.first, node, curr++, col);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> k;
  deg.resize(n + 1);
  g.resize(n + 1);
  ans.resize(n - 1);
  for (long long int i = 0; i < n - 1; i++) {
    long long int u, v;
    cin >> u >> v;
    g[u].push_back({v, i});
    g[v].push_back({u, i});
    deg[u]++;
    deg[v]++;
  }
  sort(deg.begin() + 1, deg.end());
  long long int col = deg[n];
  if (k) {
    col = deg[n - k];
  }
  dfs(1, 0, 0, col);
  cout << col << "\n";
  for (auto &x : ans) {
    cout << x << " ";
  }
  cout << "\n";
}
