#include <bits/stdc++.h>   using namespace std;   template <typename T>   inline T maxi(T a, T b) {     return a > b ? a : b;   }   template <typename T>   inline T mini(T a, T b) {     return a < b ? a : b;   }   template <typename T>   inline T absl(T a) {     return a > 0 ? a : -a;   }   template <typename T>   inline T gcd(T a, T b) {     T t;     if (a < b) {       while (a) {         t = a;         a = b % a;         b = t;       }       return b;     } else {       while (b) {         t = b;         b = a % b;         a = t;       }       return a;     }   }   template <typename T>   inline T ceiling(T a, T b) {     if (b < 0) {       a *= -1;       b *= -1;     }     if ((double)a / (double)b < 0) return 0;     {       if (a % b == 0) return (a / b);       return ((a / b) + 1);     }   }   vector<int> adj[500000];   map<pair<int, int>, int> m;   vector<pair<int, int> > v(500000);   vector<bool> visited(500000, false);   int d;   void dfs(int u, int c) {     visited[u] = true;     for (auto it : adj[u]) {       if (!visited[it]) {         m[{u, it}] = c % d;         ++c;         dfs(it, c);       }     }   }   void input() {     int n, k;     cin >> n >> k;     for (int i = 0; i < n - 1; ++i) {       int s, d;       cin >> s >> d;       --s;       --d;       adj[s].push_back(d);       adj[d].push_back(s);       v[i].first = s;       v[i].second = d;     }     int b[n];     for (int i = 0; i < n; ++i) {       b[i] = adj[i].size();     }     sort(b, b + n, greater<int>());     d = b[k];     cout << d << endl;     dfs(0, 0);     for (int i = 0; i < n - 1; ++i) {       cout << maxi(m[v[i]], m[{v[i].second, v[i].first}]) + 1 <<    ;     }   }   int main() {     input();     return 0;   }   