#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 9;
const long long mod = 998244353;
int n, m;
vector<int> g[N];
namespace dsu {
int fa[N], v[N];
int find(int x) {
  if (fa[x] == x) return x;
  int f = fa[x];
  fa[x] = find(f);
  v[x] ^= v[f];
  return fa[x];
}
void build() {
  for (int i = (1); i < (n + 1); ++i) fa[i] = i, v[i] = 0;
}
void merge(int x, int y, int vv) {
  int px = find(x), py = find(y);
  if (px == py) {
    if (v[x] ^ v[y] ^ vv) {
      printf("-1");
      exit(0);
    }
  } else {
    fa[px] = py;
    v[px] = v[x] ^ v[y] ^ vv;
  }
}
}  // namespace dsu
namespace TR {
int fa[N], S[N], SS[N], sz[N], top[N], dfn[N], pos[N], dep[N];
void dfs(int u) {
  sz[u] = 1;
  for (auto v : g[u]) {
    if (v == fa[u]) continue;
    dep[v] = dep[u] + 1, fa[v] = u;
    dfs(v);
    sz[u] += sz[v];
  }
}
void dfs2(int u, int tp) {
  top[u] = tp;
  dfn[u] = ++*dfn;
  pos[*dfn] = u;
  int k = 0;
  for (auto v : g[u]) {
    if (v == fa[u]) continue;
    if (sz[v] > sz[k]) k = v;
  }
  if (k) dfs2(k, tp);
  for (auto v : g[u]) {
    if (v == fa[u] || v == k) continue;
    dfs2(v, v);
  }
}
void build() {
  dfs(1);
  dfs2(1, 1);
}
int LCA(int u, int v) {
  for (; top[u] != top[v]; u = fa[top[u]]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
  }
  return dep[u] < dep[v] ? u : v;
}
int jmp(int x, int f) {
  for (;;) {
    if (dep[top[x]] == dep[top[f]]) return pos[dfn[f] + 1];
    if (dep[top[x]] == dep[f] + 1) return top[x];
    x = fa[top[x]];
  }
}
void cont(int u, int v) {
  int f = LCA(u, v);
  ++S[u], ++S[v], S[f] -= 2;
  if (u ^ f) ++SS[u], --SS[u = jmp(u, f)];
  if (v ^ f) ++SS[v], --SS[v = jmp(v, f)];
  if ((u ^ f) && (v ^ f)) dsu::merge(u, v, 1);
}
void build2() {
  for (int i = (n + 1) - 1; i >= (1); --i) {
    int u = pos[i];
    S[fa[u]] += S[u];
    SS[fa[u]] += SS[u];
    if (SS[u]) dsu::merge(u, fa[u], 0);
  }
}
}  // namespace TR
int q[N], dp[N], v0[N], v1[N], T, vis[N], tag[N], c[N];
bool check(int K) {
  for (int i = (n + 1) - 1; i >= (1); --i) {
    int u = TR::pos[i], f = TR::fa[u];
    *q = 0;
    ++T;
    for (auto v : g[u]) {
      if (v == f || !TR::S[v]) continue;
      int x = dsu::find(v);
      if (vis[x] != T) vis[x] = T, v0[x] = 0, v1[x] = 0, q[++*q] = x;
      if (!dsu::v[v])
        v0[x] = max(v0[x], dp[v]);
      else
        v1[x] = max(v1[x], dp[v]);
    }
    int vl = 0, vr = 0;
    if (T == vis[dsu::fa[u]]) {
      int x = dsu::fa[u];
      vl = v0[x], vr = v1[x];
      if (dsu::v[u]) swap(vl, vr);
    }
    int vmn = 0, vmx = 0;
    for (int j = (1); j < ((*q) + 1); ++j) {
      if (dsu::fa[u] != q[j]) {
        if (v0[q[j]] > v1[q[j]]) swap(v0[q[j]], v1[q[j]]);
        vmn = max(vmn, v0[q[j]]);
        vmx = max(vmx, v1[q[j]]);
      }
    }
    if (max(vmn, min(vl, vr)) + max(vmx, max(vl, vr)) >= K) return 0;
    dp[u] =
        (max(vmn, vl) + max(vmx, vr) >= K ? max(vmx, vl) : max(vmn, vl)) + 1;
  }
  return 1;
}
void construct(int K) {
  for (int i = (1); i < (n + 1); ++i) {
    int u = TR::pos[i], f = TR::fa[u];
    *q = 0;
    ++T;
    for (auto v : g[u]) {
      if (v == f || !TR::S[v]) continue;
      int x = dsu::fa[v];
      if (vis[x] != T) vis[x] = T, v0[x] = 0, v1[x] = 0, q[++*q] = x;
      if (!dsu::v[v])
        v0[x] = max(v0[x], dp[v]);
      else
        v1[x] = max(v1[x], dp[v]);
    }
    for (int j = (1); j < ((*q) + 1); ++j) {
      c[q[j]] = tag[u];
      if (q[j] != dsu::fa[u])
        c[q[j]] ^= (v0[q[j]] > dp[u] - 1 || v1[q[j]] + dp[u] > K);
      else
        c[q[j]] ^= dsu::v[u];
    }
    for (auto v : g[u]) {
      if (v == f || !TR::S[v]) continue;
      tag[v] = c[dsu::fa[v]] ^ dsu::v[v];
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (1); i < (n); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  TR::build();
  dsu::build();
  for (int i = (0); i < (m); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    TR::cont(u, v);
  }
  TR::build2();
  for (int i = (1); i < (n + 1); ++i) dsu::find(i);
  int l = 1, r = n;
  while (l < r) {
    int mid = l + r >> 1;
    if (check(mid))
      r = mid;
    else
      l = mid + 1;
  }
  check(l);
  construct(l);
  printf("%d\n", l);
  for (int i = (1); i < (n + 1); ++i)
    printf("%d ", !tag[i] ? dp[i] : l + 1 - dp[i]);
}
