#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int n, k;
vector<int> a[200010];
pair<int, pair<int, int> > down[200010];
pair<int, pair<int, int> > downid[200010];
int up[200010];
bool vis[200010];
pair<int, pair<int, int> > dfs(int x) {
  vis[x] = 1;
  pair<int, pair<int, int> > ans = make_pair(0, make_pair(0, 0));
  pair<int, pair<int, int> > id = make_pair(0, make_pair(0, 0));
  vector<pair<int, int> > v;
  for (int i = 0; i < a[x].size(); i++) {
    if (!vis[a[x][i]]) v.push_back(make_pair(dfs(a[x][i]).first + 1, a[x][i]));
  }
  sort(v.begin(), v.end(), greater<pair<int, int> >());
  if (v.size() >= 1) {
    ans.first = v[0].first;
    id.first = v[0].second;
  }
  if (v.size() >= 2) {
    ans.second.first = v[1].first;
    id.second.first = v[1].second;
  }
  if (v.size() >= 3) {
    ans.second.second = v[2].first;
    id.second.second = v[2].second;
  }
  down[x] = ans;
  downid[x] = id;
  return ans;
}
void dfs2(int x, int anc) {
  vis[x] = 1;
  int ans = 0;
  if (anc) {
    if (downid[anc].first != x) ans = max(ans, down[anc].first + 1);
    if (downid[anc].second.first != x)
      ans = max(ans, down[anc].second.first + 1);
    if (downid[anc].second.second != x)
      ans = max(ans, down[anc].second.second + 1);
    ans = max(ans, up[anc] + 1);
  }
  up[x] = ans;
  for (int i = 0; i < a[x].size(); i++)
    if (!vis[a[x][i]]) dfs2(a[x][i], x);
}
bool pan(pair<int, pair<int, int> > x, int y) {
  int a[4];
  a[0] = x.first;
  a[1] = x.second.first;
  a[2] = x.second.second;
  a[3] = y;
  sort(a, a + 4);
  int cnt = 0;
  for (int i = 0; i < int(4); i++)
    if (a[i] > 0) cnt++;
  if (cnt >= 3 && a[1] + a[2] >= k - 1) return 0;
  return 1;
}
int dep[200010];
int nowdep;
void dfs3(int x) {
  vis[x] = 1;
  dep[x] = nowdep;
  for (int i = 0; i < int(a[x].size()); i++) {
    if (!vis[a[x][i]]) {
      nowdep++;
      dfs3(a[x][i]);
      nowdep--;
    }
  }
}
pair<int, int> depanc[200010];
void dfs4(int x, int anc) {
  vis[x] = 1;
  depanc[x] = make_pair(nowdep, anc);
  for (int i = 0; i < int(a[x].size()); i++) {
    if (!vis[a[x][i]]) {
      nowdep++;
      dfs4(a[x][i], x);
      nowdep--;
    }
  }
}
int nxt(int x) {
  if (x == k) return 1;
  return x + 1;
}
int prev(int x) {
  if (x == 1) return k;
  return x - 1;
}
vector<int> dia;
int op[200010];
void dfsleft(int x, int col) {
  vis[x] = 1;
  op[x] = col;
  for (int i = 0; i < int(a[x].size()); i++) {
    if (!vis[a[x][i]]) {
      dfsleft(a[x][i], prev(col));
    }
  }
}
void dfsright(int x, int col) {
  vis[x] = 1;
  op[x] = col;
  for (int i = 0; i < int(a[x].size()); i++) {
    if (!vis[a[x][i]]) {
      dfsright(a[x][i], nxt(col));
    }
  }
}
int opfor2[200010];
int nownum = 1;
void dfsfor2(int x) {
  vis[x] = 1;
  opfor2[x] = nownum;
  for (int i = 0; i < int(a[x].size()); i++) {
    if (!vis[a[x][i]]) {
      nownum = 3 - nownum;
      dfsfor2(a[x][i]);
      nownum = 3 - nownum;
    }
  }
}
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 0; i < int(n - 1); i++) {
    int x, y;
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  if (k == 2) {
    dfsfor2(1);
    cout << "YES" << endl;
    for (int i = 1; i <= int(n); i++) cout << opfor2[i] << " ";
    cout << endl;
    return 0;
  }
  for (int i = 1; i <= int(n); i++) vis[i] = 0;
  dfs(1);
  for (int i = 1; i <= int(n); i++) vis[i] = 0;
  dfs2(1, 0);
  bool ok = 1;
  for (int i = 1; i <= int(n); i++) {
    if (!pan(down[i], up[i])) {
      ok = 0;
      break;
    }
  }
  if (!ok) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  for (int i = 1; i <= int(n); i++) vis[i] = 0;
  dfs3(1);
  int st = max_element(dep + 1, dep + 1 + n) - dep;
  for (int i = 1; i <= int(n); i++) vis[i] = 0;
  nowdep = 0;
  dfs4(st, 0);
  int en = max_element(depanc + 1, depanc + 1 + n) - depanc;
  while (en) {
    dia.push_back(en);
    en = depanc[en].second;
  }
  for (int i = 1; i <= int(n); i++) vis[i] = 0;
  int nowcol = 1;
  for (int i = 0; i < int(dia.size()); i++) {
    op[dia[i]] = nowcol;
    nowcol = nxt(nowcol);
    vis[dia[i]] = 1;
  }
  for (int i = 0; i < int(dia.size()); i++) {
    if (i < dia.size() / 2)
      dfsleft(dia[i], op[dia[i]]);
    else
      dfsright(dia[i], op[dia[i]]);
  }
  for (int i = 1; i <= int(n); i++) cout << op[i] << " ";
  cout << endl;
}
