#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> adjList[500000];
pair<int, int> ds[500000], num[500000], temp[500000];
int bad = 0;
pair<int, int> find(int n) {
  if (ds[n].first != n) {
    pair<int, int> p = find(ds[n].first);
    ds[n] = make_pair(p.first, p.second ^ ds[n].second);
  }
  return ds[n];
}
int merge(int a, int b, int e) {
  pair<int, int> pa = find(a), push_back = find(b);
  e ^= pa.second ^ push_back.second;
  if (pa.first == push_back.first) {
    if (e) bad = 1;
    return 0;
  }
  ds[pa.first] = make_pair(push_back.first, e);
  return 0;
}
int parent[500000][19], toUpdate[500000][19], depth[500000];
int doDFS(int u, int p, int d) {
  int i;
  parent[u][0] = p, depth[u] = d;
  for (i = 0; i < adjList[u].size(); i++) {
    int v = adjList[u][i];
    if (v != p) doDFS(v, u, d + 1);
  }
  return 0;
}
int ans, dp[500000];
int doDFS2(int u) {
  int i;
  vector<pair<int, int> > c;
  for (i = 0; i < adjList[u].size(); i++) {
    int v = adjList[u][i];
    if (v != parent[u][0]) {
      doDFS2(v);
      if (dp[v] == 1e9) {
        dp[u] = 1e9;
        return 0;
      } else
        c.push_back(make_pair(dp[v], v));
    }
  }
  if (!c.empty()) swap(*max_element(c.begin(), c.end()), c[0]);
  for (i = 0; i < c.size(); i++) num[find(c[i].second).first] = make_pair(0, 0);
  for (i = 1; i < c.size(); i++) {
    if (c[i].first + c[0].first > ans) {
      pair<int, int> p = find(c[i].second);
      if (p.first == find(c[0].second).first) {
        if (p.second != find(c[0].second).second) {
          dp[u] = 1e9;
          return 0;
        }
      } else {
        if (temp[p.first] == make_pair(u, p.second ^ 1)) {
          dp[u] = 1e9;
          return 0;
        }
        temp[p.first] = make_pair(u, p.second);
      }
    }
  }
  dp[u] = (u != 0);
  pair<int, int> pu = find(u);
  if ((temp[pu.first].first == u) && (pu.first != find(c[0].second).first))
    pu = make_pair(find(c[0].second).first, pu.second ^ temp[pu.first].second ^
                                                find(c[0].second).second);
  for (i = 0; i < c.size(); i++) {
    pair<int, int> p = find(c[i].second);
    if (temp[p.first].first == u)
      p = make_pair(find(c[0].second).first,
                    p.second ^ temp[p.first].second ^ find(c[0].second).second);
    if (p.first == pu.first) {
      if (!(p.second ^ pu.second)) dp[u] = max(dp[u], c[i].first + (u != 0));
    }
    if (p.second)
      num[p.first].second = max(num[p.first].second, c[i].first);
    else
      num[p.first].first = max(num[p.first].first, c[i].first);
    dp[u] = max(dp[u], min(num[p.first].first, num[p.first].second) + (u != 0));
  }
  if (dp[u] > ans) {
    dp[u] = 1e9;
    return 0;
  }
  return 0;
}
vector<int> adjList2[500000];
int doDFS3(int u, int f) {
  int i;
  vector<pair<int, int> > c;
  if (u != 0) {
    if (f)
      adjList2[parent[u][0]].push_back(u);
    else
      adjList2[u].push_back(parent[u][0]);
  }
  for (i = 0; i < adjList[u].size(); i++) {
    int v = adjList[u][i];
    if (v != parent[u][0]) c.push_back(make_pair(dp[v], v));
  }
  if (!c.empty()) swap(*max_element(c.begin(), c.end()), c[0]);
  for (i = 0; i < c.size(); i++) num[find(c[i].second).first] = make_pair(0, 0);
  for (i = 1; i < c.size(); i++) {
    if (c[i].first + c[0].first > ans) {
      pair<int, int> p = find(c[i].second);
      if (p.first != find(c[0].second).first)
        temp[p.first] = make_pair(u, p.second);
    }
  }
  pair<int, int> pu = find(u);
  if ((temp[pu.first].first == u) && (pu.first != find(c[0].second).first))
    pu = make_pair(find(c[0].second).first, pu.second ^ temp[pu.first].second ^
                                                find(c[0].second).second);
  for (i = 0; i < c.size(); i++) {
    pair<int, int> p = find(c[i].second);
    if (temp[p.first].first == u)
      p = make_pair(find(c[0].second).first,
                    p.second ^ temp[p.first].second ^ find(c[0].second).second);
    if (p.second)
      num[p.first].second = max(num[p.first].second, c[i].first);
    else
      num[p.first].first = max(num[p.first].first, c[i].first);
  }
  for (i = 0; i < c.size(); i++) {
    pair<int, int> p = find(c[i].second);
    if (temp[p.first].first == u)
      p = make_pair(find(c[0].second).first,
                    p.second ^ temp[p.first].second ^ find(c[0].second).second);
    if (p.first == pu.first)
      c[i].first = f ^ p.second ^ pu.second;
    else if (num[p.first].first < num[p.first].second)
      c[i].first = f ^ p.second;
    else
      c[i].first = f ^ p.second ^ 1;
  }
  for (i = 0; i < c.size(); i++) doDFS3(c[i].second, c[i].first);
  return 0;
}
queue<int> Q;
int in[500000], c[500000];
int main() {
  int i, j;
  int m, u, v;
  scanf("%d %d", &n, &m);
  for (i = 0; i < n - 1; i++) {
    scanf("%d %d", &u, &v);
    u--, v--;
    adjList[u].push_back(v);
    adjList[v].push_back(u);
  }
  for (i = 0; i < n; i++) ds[i] = make_pair(i, 0);
  doDFS(0, -1, 0);
  for (i = 1; (1 << i) < n; i++) {
    for (j = 0; j < n; j++) {
      if (parent[j][i - 1] != -1)
        parent[j][i] = parent[parent[j][i - 1]][i - 1];
      else
        parent[j][i] = -1;
    }
  }
  int logn = i;
  for (i = 0; i < m; i++) {
    scanf("%d %d", &u, &v);
    u--, v--;
    if (depth[u] < depth[v]) swap(u, v);
    for (j = logn - 1; j >= 0; j--) {
      if ((parent[u][j] != -1) && (depth[parent[u][j]] >= depth[v]) &&
          (parent[u][j] != v)) {
        toUpdate[u][j] = 1;
        u = parent[u][j];
      }
    }
    if (parent[u][0] != v) {
      for (j = logn - 1; j >= 0; j--) {
        if (parent[u][j] != parent[v][j]) {
          toUpdate[u][j] = toUpdate[v][j] = 1;
          u = parent[u][j], v = parent[v][j];
        }
      }
      merge(u, v, 1);
    }
  }
  for (i = logn - 1; i > 0; i--) {
    for (j = 0; j < n; j++) {
      if (toUpdate[j][i])
        toUpdate[j][i - 1] = toUpdate[parent[j][i - 1]][i - 1] = 1;
    }
  }
  for (i = 0; i < n; i++) {
    if (toUpdate[i][0]) merge(i, parent[i][0], 0);
  }
  if (bad) {
    printf("-1\n");
    return 0;
  }
  int l = 0, r = n - 1;
  while (l < r) {
    int m = (l + r) / 2;
    if ((l == 0) && (r == n - 1)) m = n - sqrt(n) - 1;
    ans = m;
    fill(temp, temp + n, make_pair(-1, -1));
    doDFS2(0);
    if (dp[0] < 1e9)
      r = m;
    else
      l = m + 1;
  }
  ans = l;
  printf("%d\n", l + 1);
  fill(temp, temp + n, make_pair(-1, -1));
  doDFS2(0);
  fill(temp, temp + n, make_pair(-1, -1));
  doDFS3(0, 0);
  for (i = 0; i < n; i++) {
    for (j = 0; j < adjList2[i].size(); j++) in[adjList2[i][j]]++;
  }
  for (i = 0; i < n; i++) {
    if (in[i] == 0) Q.push(i), c[i] = 1;
  }
  while (!Q.empty()) {
    int u = Q.front();
    Q.pop();
    for (i = 0; i < adjList2[u].size(); i++) {
      int v = adjList2[u][i];
      in[v]--;
      if (in[v] == 0) c[v] = c[u] + 1, Q.push(v);
    }
  }
  for (i = 0; i < n; i++) printf("%d ", c[i]);
  printf("\n");
  return 0;
}
