#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 7;
int hd[N], pre[N << 1], to[N << 1], num;
int dep[N], anc[N][23], dfn[N], ord, fa[N];
int ff[N], cov[N], cong[N], op[N];
int n, m;
vector<int> E[N];
map<int, vector<int> > G[N];
int find(int x) {
  if (x == ff[x]) return x;
  int f = ff[x];
  ff[x] = find(ff[x]);
  op[x] ^= op[f];
  return ff[x];
}
void merge(int x, int y, int v) {
  int xx = find(x), yy = find(y);
  if (xx == yy) {
    if (op[x] ^ op[y] ^ v) {
      puts("-1");
      exit(0);
    }
  } else {
    ff[xx] = yy;
    op[xx] = op[x] ^ v ^ op[y];
  }
}
void dfs(int v, int ffa) {
  dep[v] = dep[ffa] + 1;
  dfn[++ord] = v;
  fa[v] = ffa;
  anc[v][0] = fa[v];
  for (int i = 1; i <= 20; i++) anc[v][i] = anc[anc[v][i - 1]][i - 1];
  for (int i = hd[v]; i; i = pre[i]) {
    int u = to[i];
    if (u == ffa) continue;
    dfs(u, v);
  }
}
int glca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 20; i >= 0; i--)
    if (dep[x] - (1 << i) >= dep[y]) x = anc[x][i];
  if (x == y) return x;
  for (int i = 20; i >= 0; i--)
    if (anc[x][i] != anc[y][i]) x = anc[x][i], y = anc[y][i];
  return anc[x][0];
}
int jump(int x, int y) {
  for (int i = 20; i >= 0; i--)
    if (dep[x] - (1 << i) > dep[y]) x = anc[x][i];
  return x;
}
int f[N], rev[N];
bool check(int k) {
  for (int i = 1; i <= n; i++) f[i] = rev[i] = 0;
  for (int o = n; o >= 1; o--) {
    int v = dfn[o];
    int nl = 1, nr = k, flag = op[v] ? 0 : 1;
    for (auto u : E[v]) {
      if (op[u] ^ flag)
        nl = max(nl, f[u] + 1);
      else
        nr = min(nr, k - f[u]), rev[u] ^= 1;
    }
    if (nl > nr) return false;
    int ml = 1, mr = k;
    for (auto ve : G[v]) {
      int l = 1, r = k;
      for (auto u : ve.second) {
        if (op[u])
          l = max(l, f[u] + 1);
        else
          r = min(r, k - f[u]), rev[u] ^= 1;
      }
      if (l > r) return false;
      if (l > k - r + 1) {
        swap(l, r), l = k + 1 - l, r = k + 1 - r;
        for (auto u : ve.second) rev[u] ^= 1;
      }
      ml = max(ml, l), mr = min(mr, r);
    }
    if (ml > mr) return false;
    if (max(nl, ml) <= min(nr, mr))
      f[v] = max(nl, ml);
    else {
      swap(ml, mr), ml = k + 1 - ml, mr = k + 1 - mr;
      if (max(nl, ml) <= min(nr, mr)) {
        f[v] = max(nl, ml);
        for (auto ve : G[v])
          for (auto u : ve.second) rev[u] ^= 1;
      } else
        return false;
    }
  }
  return true;
}
int ans[N];
void get(int k) {
  ans[1] = f[1];
  for (int o = 2; o <= n; o++) {
    int v = dfn[o];
    rev[v] ^= rev[fa[v]];
    if (rev[v])
      ans[v] = k + 1 - f[v];
    else
      ans[v] = f[v];
  }
}
void adde(int x, int y) {
  num++;
  pre[num] = hd[x];
  hd[x] = num;
  to[num] = y;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    adde(x, y), adde(y, x);
  }
  for (int i = 1; i <= n; i++) ff[i] = i, op[i] = 0;
  dfs(1, 0);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (dep[x] > dep[y]) swap(x, y);
    int lca = glca(x, y);
    cov[x]++, cov[y]++, cov[lca] -= 2;
    if (x == lca)
      cong[y]++, cong[jump(y, lca)]--;
    else {
      int u = jump(x, lca), v = jump(y, lca);
      cong[x]++, cong[u]--;
      cong[y]++, cong[v]--;
      merge(u, v, 1);
    }
  }
  for (int o = n; o >= 2; o--) {
    int v = dfn[o], u = fa[v];
    cong[u] += cong[v], cov[u] += cov[v];
  }
  for (int i = 1; i <= n; i++)
    if (cong[i]) merge(i, fa[i], 0);
  for (int i = 1; i <= n; i++) find(i);
  for (int i = 2; i <= n; i++)
    if (cov[i]) {
      if (find(i) == find(fa[i]))
        E[fa[i]].push_back(i);
      else
        G[fa[i]][find(i)].push_back(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), get(l);
  printf("%d\n", l);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  return 0;
}
