#include <bits/stdc++.h>
using namespace std;
const int N = 100009;
const int INF = 1e9;
const int MOD = INF + 7;
int n, m;
vector<int> g[4 * N];
vector<int> gg[4 * N];
int f[4 * N], ff[4 * N], timer;
bool u[4 * N];
pair<int, int> cover[4 * N];
vector<pair<int, int> > add[4 * N];
int ans[4 * N];
pair<int, int> tree[N * 4];
int upd[4 * N];
void push(int v, int l, int r) {
  tree[v].first += upd[v];
  if (l != r) {
    upd[v * 2 + 1] += upd[v];
    upd[v * 2 + 2] += upd[v];
  }
  upd[v] = 0;
}
int get_min() {
  push(0, 0, n);
  return (tree[0].first == 0 ? n - tree[0].second : n);
}
pair<int, int> zbs(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first) return make_pair(a.first, a.second + b.second);
  return min(a, b);
}
void inc(int v, int l, int r, int L, int R, int val) {
  push(v, l, r);
  if (l == L && r == R) {
    upd[v] += val;
    push(v, l, r);
    return;
  }
  int m = (l + r) / 2;
  if (R <= m) inc(v * 2 + 1, l, m, L, R, val);
  if (L > m) inc(v * 2 + 2, m + 1, r, L, R, val);
  if (L <= m && R > m) {
    inc(v * 2 + 1, l, m, L, m, val);
    inc(v * 2 + 2, m + 1, r, m + 1, R, val);
  }
  push(v * 2 + 1, l, m);
  push(v * 2 + 2, m + 1, r);
  tree[v] = zbs(tree[v * 2 + 1], tree[v * 2 + 2]);
}
void build(int v, int l, int r) {
  if (l == r) {
    if (r < n) tree[v] = make_pair(0, 1);
    return;
  }
  int m = (l + r) >> 1;
  build(v * 2 + 1, l, m);
  build(v * 2 + 2, m + 1, r);
  tree[v] = zbs(tree[v * 2 + 1], tree[v * 2 + 2]);
}
void dfs(int v) {
  u[v] = true;
  int now_timer = timer;
  f[v] = timer;
  ff[timer] = v;
  cover[timer].first = timer;
  ++timer;
  for (int i = 0; i < (int)(g[v].size()); ++i)
    if (!u[g[v][i]]) {
      dfs(g[v][i]);
      gg[now_timer].push_back(f[g[v][i]]);
    }
  cover[now_timer].second = timer - 1;
}
void dfs1(int v) {
  u[v] = true;
  for (int i = 0; i < (int)(add[v].size()); ++i)
    inc(0, 0, N - 1, add[v][i].first, add[v][i].second, 1);
  ans[ff[v]] = max(get_min() - 1, 0);
  for (int i = 0; i < (int)(gg[v].size()); ++i)
    if (!u[gg[v][i]]) dfs1(gg[v][i]);
  for (int i = 0; i < (int)(add[v].size()); ++i)
    inc(0, 0, N - 1, add[v][i].first, add[v][i].second, -1);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < (int)(n - 1); ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(0);
  for (int i = 0; i < (int)(m); ++i) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    add[f[x]].push_back(make_pair(cover[f[x]].first, cover[f[x]].second));
    add[f[x]].push_back(cover[f[y]]);
    add[f[y]].push_back(make_pair(cover[f[y]].first, cover[f[y]].second));
    add[f[y]].push_back(cover[f[x]]);
  }
  build(0, 0, N - 1);
  memset(u, 0, sizeof u);
  dfs1(0);
  for (int i = 0; i < (int)(n); ++i) cout << ans[i] << ' ';
}
