#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class t, class u>
void chmax(t& first, u second) {
  if (first < second) first = second;
}
template <class t, class u>
void chmin(t& first, u second) {
  if (second < first) first = second;
}
template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;
using pi = pair<int, int>;
using vi = vc<int>;
template <class t, class u>
ostream& operator<<(ostream& os, const pair<t, u>& p) {
  return os << "{" << p.first << "," << p.second << "}";
}
template <class t>
ostream& operator<<(ostream& os, const vc<t>& v) {
  os << "{";
  for (auto e : v) os << e << ",";
  return os << "}";
}
using uint = unsigned;
using ull = unsigned long long;
template <class t, size_t n>
ostream& operator<<(ostream& os, const array<t, n>& first) {
  return os << vc<t>(first.begin(), first.end());
}
template <int i, class T>
void print_tuple(ostream&, const T&) {}
template <int i, class T, class H, class... Args>
void print_tuple(ostream& os, const T& t) {
  if (i) os << ",";
  os << get<i>(t);
  print_tuple<i + 1, T, Args...>(os, t);
}
template <class... Args>
ostream& operator<<(ostream& os, const tuple<Args...>& t) {
  os << "{";
  print_tuple<0, tuple<Args...>, Args...>(os, t);
  return os << "}";
}
template <class t>
void print(t x, int suc = 1) {
  cout << x;
  if (suc == 1) cout << "\n";
  if (suc == 2) cout << " ";
}
ll read() {
  ll i;
  cin >> i;
  return i;
}
vi readvi(int n, int off = 0) {
  vi v(n);
  for (int i = int(0); i < int(n); i++) v[i] = read() + off;
  return v;
}
template <class T>
void print(const vector<T>& v, int suc = 1) {
  for (int i = int(0); i < int(v.size()); i++)
    print(v[i], i == int(v.size()) - 1 ? suc : 2);
}
string readString() {
  string s;
  cin >> s;
  return s;
}
template <class T>
T sq(const T& t) {
  return t * t;
}
void yes(bool ex = true) {
  cout << "Yes"
       << "\n";
  if (ex) exit(0);
}
void no(bool ex = true) {
  cout << "No"
       << "\n";
  if (ex) exit(0);
}
void possible(bool ex = true) {
  cout << "Possible"
       << "\n";
  if (ex) exit(0);
}
void impossible(bool ex = true) {
  cout << "Impossible"
       << "\n";
  if (ex) exit(0);
}
constexpr ll ten(int n) { return n == 0 ? 1 : ten(n - 1) * 10; }
const ll infLL = LLONG_MAX / 3;
const int inf = INT_MAX / 2 - 100;
int topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); }
int topbit(ll t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); }
int botbit(signed first) { return first == 0 ? 32 : __builtin_ctz(first); }
int botbit(ll first) { return first == 0 ? 64 : __builtin_ctzll(first); }
int popcount(signed t) { return __builtin_popcount(t); }
int popcount(ll t) { return __builtin_popcountll(t); }
bool ispow2(int i) { return i && (i & -i) == i; }
ll mask(int i) { return (ll(1) << i) - 1; }
bool inc(int first, int second, int c) {
  return first <= second && second <= c;
}
template <class t>
void mkuni(vc<t>& v) {
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
}
ll rand_int(ll l, ll r) {
  static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
  return uniform_int_distribution<ll>(l, r)(gen);
}
template <class t>
void myshuffle(vc<t>& first) {
  for (int i = int(0); i < int(int(first.size())); i++)
    swap(first[i], first[rand_int(0, i)]);
}
template <class t>
int lwb(const vc<t>& v, const t& first) {
  return lower_bound(v.begin(), v.end(), first) - v.begin();
}
struct unionfind {
  vi p, s;
  int c;
  unionfind(int n = 0) : p(n, -1), s(n, 1), c(n) {}
  int find(int first) {
    return p[first] == -1 ? first : (p[first] = find(p[first]));
  }
  bool unite(int first, int second) {
    first = find(first);
    second = find(second);
    if (first == second) return false;
    p[second] = first;
    s[first] += s[second];
    c--;
    return true;
  }
  bool same(int first, int second) { return find(first) == find(second); }
  int sz(int first) { return s[find(first)]; }
};
template <class t>
vi toposort(vvc<t> g) {
  int n = g.size();
  vi first(n);
  for (int i = int(0); i < int(n); i++)
    for (auto e : g[i]) first[e]++;
  queue<int> q;
  for (int i = int(0); i < int(n); i++)
    if (first[i] == 0) q.push(i);
  vi res;
  for (int i = int(0); i < int(n); i++) {
    if (q.empty()) return {};
    int v = q.front();
    q.pop();
    res.push_back(v);
    for (auto e : g[v])
      if (--first[e] == 0) q.push(e);
  }
  return res;
}
template <class E>
struct HLD {
  vvc<E> g;
  int n, rt, cnt;
  vi sub, in, out, par, head, dep;
  int dfs1(int v, int p, int d) {
    par[v] = p;
    dep[v] = d;
    g[v].erase(remove(g[v].begin(), g[v].end(), p), g[v].end());
    for (auto& e : g[v]) {
      sub[v] += dfs1(e, v, d + 1);
      if (sub[g[v][0]] < sub[e]) swap(g[v][0], e);
    }
    return sub[v];
  }
  void dfs2(int v, int h) {
    in[v] = cnt++;
    head[v] = h;
    for (int to : g[v]) dfs2(to, to == g[v][0] ? h : to);
    out[v] = cnt;
  }
  HLD() {}
  HLD(const vvc<E>& gg, int rr)
      : g(gg),
        n(g.size()),
        rt(rr),
        cnt(0),
        sub(n, 1),
        in(n),
        out(n),
        par(n, -1),
        head(n),
        dep(n) {
    dfs1(rt, -1, 0);
    dfs2(rt, rt);
  }
  int lca(int first, int second) {
    while (head[first] != head[second]) {
      if (dep[head[first]] > dep[head[second]]) swap(first, second);
      second = par[head[second]];
    }
    if (dep[first] > dep[second]) swap(first, second);
    return first;
  }
  int len(int first, int second) {
    return dep[first] + dep[second] - dep[lca(first, second)] * 2;
  }
  bool asde(int first, int second) {
    return in[first] <= in[second] && out[second] <= out[first];
  }
  unionfind uf;
  vi has, dif;
  int k;
  vc<pi> buf;
  int ac(int v) { return uf.find(v * 2) / 2; }
  vi memo;
  int dfs(int v) {
    for (auto to : g[v]) {
      memo[to] = dfs(to);
    }
    buf[ac(v)] = pi(0, k);
    for (auto to : g[v]) {
      buf[ac(to)] = pi(0, k);
    }
    for (auto to : g[v]) {
      int w = memo[to];
      if (w == inf) return inf;
      int i = uf.find(to * 2);
      int t = i % 2;
      i /= 2;
      if (!has[i]) continue;
      if (t == 0) {
        chmax(buf[i].first, w + 1);
      } else {
        chmin(buf[i].second, k - w - 1);
      }
      if (buf[i].second < buf[i].first) return inf;
    }
    for (int waf = int(0); waf < int(2); waf++) {
      int vac = uf.find(v * 2);
      int vt = vac % 2;
      vac /= 2;
      int lw, up;
      tie(lw, up) = buf[vac];
      if (vt) {
        tie(lw, up) = pi(k - up, k - lw);
      }
      for (auto to : g[v]) {
        int i = uf.find(to * 2);
        int t = i % 2;
        i /= 2;
        if (!has[i]) continue;
        dif[to] = t;
        if (i == vac) {
          dif[to] ^= vt;
          continue;
        }
        int l, r;
        tie(l, r) = buf[i];
        if ((k - r < l) ^ waf) {
          tie(l, r) = pi(k - r, k - l);
          dif[to] ^= 1;
        }
        chmax(lw, l);
        chmin(up, r);
      }
      if (lw <= up) {
        void(0);
        return lw;
      }
    }
    return inf;
  }
  void geth(int v, int p, int t, vvc<int>& h) {
    if (has[ac(v)]) {
      if (t == 0) {
        h[v].push_back(p);
      } else {
        h[p].push_back(v);
      }
    }
    for (auto to : g[v]) {
      geth(to, v, t ^ dif[to], h);
    }
  }
  void slv(int m) {
    uf = unionfind(n * 2);
    auto unitesub = [&](int v, int p) {
      while (1) {
        v = ac(v);
        void(0);
        if (dep[v] - dep[p] >= 2) {
          void(0);
          for (int t = int(0); t < int(2); t++) {
            uf.unite(par[v] * 2 + t, v * 2 + t);
          }
          v = par[v];
        } else
          break;
      }
    };
    vi ls;
    vc<pi> es;
    for (int _ = int(0); _ < int(m); _++) {
      int first, second;
      cin >> first >> second;
      first--;
      second--;
      int c = lca(first, second);
      unitesub(first, c);
      unitesub(second, c);
      if (first != c && second != c) {
        es.emplace_back(first, second);
      }
      if (first != c)
        ls.push_back(first);
      else
        ls.push_back(second);
    }
    for (auto e : es) {
      for (int t = int(0); t < int(2); t++) {
        uf.unite(e.first * 2 + t, e.second * 2 + 1 - t);
      }
    }
    has.resize(n);
    for (auto i : ls) has[ac(i)] = 1;
    for (int i = int(0); i < int(n); i++)
      if (uf.same(i * 2, i * 2 + 1)) {
        print(-1);
        return;
      }
    dif.resize(n);
    buf.resize(n);
    memo.resize(n);
    int lw = -1, up = n - 1;
    while (up - lw > 1) {
      const int mid = (lw + up) / 2;
      k = mid;
      if (dfs(0) < inf)
        up = mid;
      else
        lw = mid;
    }
    k = up;
    void(0);
    int tmp = dfs(0);
    void(0);
    assert(tmp < inf);
    void(0);
    vvc<int> h(n);
    geth(0, -1, 0, h);
    void(0);
    void(0);
    void(0);
    vi ans(n);
    vi ord = toposort(h);
    for (auto i : ord) {
      for (auto j : h[i]) chmax(ans[j], ans[i] + 1);
    }
    for (auto& v : ans) v++;
    print(k + 1);
    print(ans);
  }
};
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
  int n, m;
  cin >> n >> m;
  vvc<int> t(n);
  for (int _ = int(0); _ < int(n - 1); _++) {
    int first, second;
    cin >> first >> second;
    first--;
    second--;
    t[first].push_back(second);
    t[second].push_back(first);
  }
  HLD<int> hld(t, 0);
  hld.slv(m);
}
