#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
int n, m, fa[N], son[N], siz[N], dep[N], top[N], cov[N], seq[N], tt, k, f[N],
    dsu[N], cov2[N];
vector<int> E[N];
pair<int, int> I[N];
bool rev[N];
int getf(int x) { return x == dsu[x] ? x : dsu[x] = getf(dsu[x]); }
void merge(int x, int y) { dsu[getf(x)] = getf(y); }
void merge(int x, int y, bool z) {
  if (!z)
    merge(x, y), merge(x + n, y + n);
  else
    merge(x, y + n), merge(x + n, y);
  if (getf(x) == getf(x + n)) {
    cout << -1;
    exit(0);
  }
}
pair<int, bool> getlim(int x) {
  int tmp = getf(x);
  if (tmp <= n) return make_pair(tmp, 0);
  return make_pair(tmp - n, 1);
}
void dfs(int u, int ff) {
  fa[u] = ff;
  siz[u] = 1;
  dep[u] = dep[ff] + 1;
  seq[++tt] = u;
  if (ff) E[u].erase(find(E[u].begin(), E[u].end(), ff));
  for (auto v : E[u]) {
    dfs(v, u);
    siz[u] += siz[v];
    if (siz[son[u]] < siz[v]) son[u] = v;
  }
}
void dfs2(int u, int tp) {
  top[u] = tp;
  if (son[u]) dfs2(son[u], tp);
  for (auto v : E[u])
    if (v != son[u]) dfs2(v, v);
}
int lca(int u, int v) {
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    u = fa[top[u]];
  }
  return dep[u] < dep[v] ? u : v;
}
int getson(int u, int v) {
  int ret = 0;
  while (top[u] != top[v]) ret = top[v], v = fa[top[v]];
  return u == v ? ret : son[u];
}
void upcov(int u) {
  for (auto v : E[u]) upcov(v), cov[u] += cov[v], cov2[u] += cov2[v];
  if (cov[u]) merge(u, fa[u], 0);
}
void getans(int u) {
  if (rev[u]) {
    f[u] = k + 1 - f[u];
    for (auto v : E[u]) rev[v] ^= 1;
  }
  for (auto v : E[u]) getans(v);
}
bool check(int mid, bool fl = 0) {
  k = mid;
  for (int i = n; i; i--) {
    int u = seq[i];
    pair<int, bool> cur = getlim(u);
    I[cur.first] = make_pair(1, k);
    for (auto v : E[u])
      if (cov2[v]) {
        pair<int, bool> tmp = getlim(v);
        I[tmp.first] = make_pair(1, k);
      }
    for (auto v : E[u])
      if (cov2[v]) {
        pair<int, bool> tmp = getlim(v);
        if (tmp.second == cur.second)
          I[tmp.first].first = max(I[tmp.first].first, f[v] + 1);
        else
          I[tmp.first].second = min(I[tmp.first].second, k - f[v]);
      }
    pair<int, int> t = make_pair(I[cur.first].first, I[cur.first].second),
                   ban = make_pair(1e9, -1e9);
    for (auto v : E[u])
      if (cov2[v]) {
        int x = getlim(v).first;
        pair<int, int> a = I[x],
                       b = make_pair(k - I[x].second + 1, k - I[x].first + 1);
        if (a > b) swap(a, b);
        if (a.first > a.second) return 0;
        if (a.second + 1 < b.first)
          ban.first = min(ban.first, a.second + 1),
          ban.second = max(ban.second, b.first - 1);
        t.first = max(t.first, a.first);
        t.second = min(t.second, b.second);
      }
    if (t.first > t.second) return 0;
    if (t.first < ban.first)
      f[u] = t.first;
    else if (ban.second < t.second)
      f[u] = ban.second + 1;
    else
      return 0;
    for (auto v : E[u])
      if (cov2[v]) {
        pair<int, bool> tmp = getlim(v);
        if (I[tmp.first].first <= f[u] && f[u] <= I[tmp.first].second)
          rev[v] = (tmp.second != cur.second);
        else
          rev[v] = (tmp.second == cur.second);
      }
  }
  if (fl) getans(1);
  return 1;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n + n; i++) dsu[i] = i;
  for (int i = 1, u, v; i < n; i++)
    u = gi(), v = gi(), E[u].push_back(v), E[v].push_back(u);
  dfs(1, 0);
  dfs2(1, 1);
  for (int i = 1; i <= m; i++) {
    int a = gi(), b = gi(), p = lca(a, b), x = 0, y = 0;
    if (a != p) ++cov[a], --cov[x = getson(p, a)];
    if (b != p) ++cov[b], --cov[y = getson(p, b)];
    ++cov2[a];
    ++cov2[b];
    cov2[p] -= 2;
    if (x && y) merge(x, y, 1);
  }
  upcov(1);
  int l = 1, r = n;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  check(l, 1);
  cout << l << '\n';
  for (int i = 1; i <= n; i++) cout << f[i] << ' ';
  return 0;
}
