#include <bits/stdc++.h>
const int N = 5e5 + 5, M = N * 2, LN = 20;
int n, m, p[LN][N], *fa = *p;
int o[N], id[N], eid[N], dep[N], cnt;
int cov[N], tag[N], bel[M];
std::vector<int> g[N];
inline void up(int &x, int y) {
  if (x < y) x = y;
}
inline void down(int &x, int y) {
  if (x > y) x = y;
}
void dfs(int u) {
  o[++cnt] = u, id[u] = cnt;
  for (int i = 0; p[i][u]; ++i) p[i + 1][u] = p[i][p[i][u]];
  for (auto v : g[u])
    if (v != fa[u]) p[0][v] = u, dep[v] = dep[u] + 1, dfs(v);
  eid[u] = cnt;
}
int jump(int u, int d) {
  assert(dep[u] >= d);
  for (int s = dep[u] - d; s; s &= s - 1) u = p[__builtin_ctz(s)][u];
  return u;
}
namespace dsu {
int p[M];
inline int get(int x) { return x == p[x] ? x : p[x] = get(p[x]); }
inline void merge(int x, int y) {
  if ((x = get(x)) != (y = get(y))) p[x] = y;
}
inline void equiv(int x, int y) { merge(x, y), merge(((x) ^ 1), ((y) ^ 1)); }
inline void init(int n) { std::iota(p, p + n + 1, 0); }
}  // namespace dsu
namespace dp {
int f[N], stamp[N], li[N];
int l[N], r[N];
bool rev[N];
inline bool main(int k) {
  memset(stamp, 0, (n + 1) * 4);
  for (int _ = n; _; --_) {
    int u = o[_];
    int top = 0, cl = 1, cr = k, cc = (k + 1) / 2;
    for (auto v : g[u]) {
      if (v == fa[u] || !cov[v]) continue;
      int B = bel[((v) << 1)], at = B / 2;
      if (stamp[at] != _) stamp[at] = _, l[at] = 1, r[at] = k, li[top++] = at;
      B & 1 ? up(l[at], f[v] + 1) : down(r[at], k - f[v]);
    }
    int B = bel[((u) << 1)], bt = B / 2;
    for (int i = 0; i < top; ++i) {
      int y = li[i];
      if (l[y] > r[y]) return false;
      if (y == bt)
        B & 1 ? (up(cl, l[y]), down(cr, r[y]))
              : (up(cl, k + 1 - r[y]), down(cr, k + 1 - l[y]));
      else
        assert((l[y] * 2 <= k + 2) || (r[y] * 2 >= k)),
            down(cc, std::min(r[y], k + 1 - l[y])),
            up(cl, std::min(l[y], k + 1 - r[y])),
            down(cr, std::max(r[y], k + 1 - l[y]));
    }
    if (cc < cl) up(cl, k + 1 - cc);
    if ((f[u] = cl) > cr) return false;
    for (auto v : g[u]) {
      if (v == fa[u]) continue;
      int B = bel[((v) << 1)], at = B / 2;
      rev[v] =
          (B ^ (at == bt ? bel[((u) << 1)] : (l[at] <= cl && cl <= r[at]))) & 1;
    }
  }
  return true;
}
inline void calc(int k) {
  printf("%d\n", k);
  for (int i = 1; i <= n; ++i) {
    int u = o[i];
    rev[u] ^= rev[fa[u]];
    if (rev[u]) f[u] = k + 1 - f[u];
  }
  for (int i = 1; i <= n; ++i) printf("%d ", f[i]);
}
}  // namespace dp
int main() {
  scanf("%d%d", &n, &m), dsu::init(((n) << 1 | 1));
  for (int i = 1, u, v; i < n; ++i)
    scanf("%d%d", &u, &v), g[u].push_back(v), g[v].push_back(u);
  for (dfs(1); m; --m) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (id[a] > id[b]) std::swap(a, b);
    if (id[b] <= eid[a]) {
      ++cov[b], --cov[a], ++tag[b], --tag[jump(b, dep[a] + 1)];
    } else {
      if (dep[a] > dep[b]) std::swap(a, b);
      int u = a, v = jump(b, dep[a]);
      for (int i = LN - 1; ~i; --i)
        if (p[i][u] != p[i][v]) u = p[i][u], v = p[i][v];
      ++cov[a], ++cov[b], cov[fa[u]] -= 2;
      ++tag[a], ++tag[b], --tag[u], --tag[v],
          dsu::equiv(((u) << 1), ((v) << 1 | 1));
    }
  }
  for (int i = n; i; --i) {
    int u = o[i];
    cov[fa[u]] += cov[u], tag[fa[u]] += tag[u];
    if (tag[u]) dsu::equiv(((u) << 1), ((fa[u]) << 1));
  }
  for (int i = 1; i <= n; ++i)
    if ((bel[((i) << 1)] = dsu::get(((i) << 1))) ==
        (bel[((i) << 1 | 1)] = dsu::get(((i) << 1 | 1))))
      return puts("-1"), 0;
  int l = 1, r = n * 2, ans;
  while (l <= r) {
    int mid = l + r >> 1;
    if (dp::main(mid))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  dp::main(ans), dp::calc(ans);
  return 0;
}
