#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 9;
int head[maxn], to[maxn << 1], nex[maxn << 1], now;
void add(int a, int b) {
  nex[++now] = head[a];
  head[a] = now;
  to[now] = b;
}
int siz[maxn], id[maxn], cnt;
void dfs(int p, int fa) {
  id[p] = ++cnt;
  siz[p] = 1;
  for (int i = head[p]; i; i = nex[i]) {
    int u = to[i];
    if (u == fa) continue;
    dfs(u, p);
    siz[p] += siz[u];
  }
}
vector<int> V[maxn];
int ans[maxn];
int laz[maxn * 100], sum[maxn * 100], ls[maxn * 100], rs[maxn * 100];
int root[maxn];
void update(int last, int now, int l, int r, int L, int R) {
  laz[now] = laz[last];
  sum[now] = sum[last];
  ls[now] = ls[last];
  rs[now] = rs[last];
  if (laz[now]) return;
  if (l >= L && r <= R) {
    laz[now] = 1;
    sum[now] = r - l + 1;
    return;
  }
  if (L <= (l + r >> 1))
    update(ls[last], ls[now] = ++cnt, l, (l + r >> 1), L, R);
  if (R > (l + r >> 1))
    update(rs[last], rs[now] = ++cnt, (l + r >> 1) + 1, r, L, R);
  sum[now] = sum[ls[now]] + sum[rs[now]];
}
int n, k;
void deal(int p, int fa) {
  root[p] = root[fa];
  for (auto q : V[p]) {
    int tmp = root[p];
    update(tmp, root[p] = ++cnt, 1, n, id[q], id[q] + siz[q] - 1);
  }
  ans[p] = max(0, sum[root[p]] - 1);
  for (int i = head[p]; i; i = nex[i]) {
    int u = to[i];
    if (u == fa) continue;
    deal(u, p);
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  for (int i = 1; i <= n - 1; i++) {
    int a, b;
    cin >> a >> b;
    add(a, b);
    add(b, a);
  }
  dfs(1, 0);
  for (int i = 1; i <= k; i++) {
    int a, b;
    cin >> a >> b;
    V[a].push_back(b);
    V[b].push_back(a);
    V[a].push_back(a);
    V[b].push_back(b);
  }
  cnt = 0;
  deal(1, 0);
  for (int i = 1; i <= n; i++) {
    printf("%d%c", ans[i], " \n"[i == n]);
  }
}
