#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
const long long maxn = 4000 * 100 + 5;
long long cn = 1, n, ans[maxn], mn[maxn], cn_mn[maxn], lzy[maxn], st[maxn],
          en[maxn];
vector<long long> aj[maxn], tree, q[maxn];
void build(long long v = 1, long long L = 0, long long R = n) {
  cn_mn[v] = R - L;
  if (R == L + 1) return;
  build((v << 1), L, ((R + L) >> 1));
  build(((v << 1) | 1), ((R + L) >> 1), R);
  return;
}
void find_st(long long v) {
  tree.push_back(cn);
  st[v] = cn;
  cn++;
  for (long long i = 0; i < (long long)(aj[v]).size(); i++) {
    long long u = aj[v][i];
    if (!st[u]) {
      find_st(u);
    }
  }
  en[v] = cn;
  cn++;
  return;
}
void shift(long long v, long long L, long long R) {
  if (lzy[v] == 0) return;
  lzy[(v << 1)] += lzy[v];
  lzy[((v << 1) | 1)] += lzy[v];
  mn[(v << 1)] += lzy[v];
  mn[((v << 1) | 1)] += lzy[v];
  lzy[v] = 0;
  return;
}
void add(long long l, long long r, long long x, long long v = 1,
         long long L = 0, long long R = n) {
  if (r <= L || R <= l) return;
  if (l <= L && R <= r) {
    lzy[v] += x;
    mn[v] += x;
    return;
  }
  shift(v, L, R);
  add(l, r, x, (v << 1), L, ((R + L) >> 1));
  add(l, r, x, ((v << 1) | 1), ((R + L) >> 1), R);
  mn[v] = min(mn[(v << 1)], mn[((v << 1) | 1)]);
  cn_mn[v] = 0;
  if (mn[v] == mn[(v << 1)]) cn_mn[v] += cn_mn[(v << 1)];
  if (mn[v] == mn[((v << 1) | 1)]) cn_mn[v] += cn_mn[((v << 1) | 1)];
  return;
}
long long get(long long l, long long r, long long v = 1, long long L = 0,
              long long R = n) {
  if (r <= L || R <= l) return 0;
  if (l <= L && R <= r) {
    if (mn[v] == 0)
      return (cn_mn[v]);
    else
      return 0;
  }
  shift(v, L, R);
  return get(l, r, (v << 1), L, ((R + L) >> 1)) +
         get(l, r, ((v << 1) | 1), ((R + L) >> 1), R);
}
void dfs(long long v) {
  for (long long i = 0; i < (long long)(q[v]).size(); i++) {
    long long u = q[v][i];
    add(st[v], en[v], 1);
    add(st[u], en[u], 1);
  }
  ans[v] = n - get(0, n);
  for (long long i = 0; i < (long long)(aj[v]).size(); i++) {
    long long u = aj[v][i];
    if (st[u] > st[v]) dfs(u);
  }
  for (long long i = 0; i < (long long)(q[v]).size(); i++) {
    long long u = q[v][i];
    add(st[v], en[v], -1);
    add(st[u], en[u], -1);
  }
  return;
}
int32_t main() {
  long long m;
  cin >> n >> m;
  build();
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    u--;
    v--;
    aj[u].push_back(v);
    aj[v].push_back(u);
  }
  find_st(0);
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    u--;
    v--;
    q[u].push_back(v);
    q[v].push_back(u);
  }
  for (long long i = 0; i < n; i++) {
    long long x = lower_bound(tree.begin(), tree.end(), st[i]) - tree.begin();
    st[i] = x;
    x = lower_bound(tree.begin(), tree.end(), en[i]) - tree.begin();
    en[i] = x;
  }
  dfs(0);
  for (long long i = 0; i < n; i++) {
    if (ans[i]) ans[i]--;
    cout << ans[i] << ' ';
  }
  return false;
}
