#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 7;
vector<int> adj[N], q[N];
int cnt[N << 2], mn[N << 2], sum[N << 2], lzy[N << 2], st[N], en[N], t, Ans[N],
    n;
void dfs(int u, int p) {
  st[u] = ++t;
  for (int v : adj[u])
    if (v != p) dfs(v, u);
  en[u] = t;
}
void propagate(int cur, int l, int r) {
  if (lzy[cur]) {
    mn[cur] += lzy[cur];
    if (!mn[cur])
      sum[cur] = cnt[cur];
    else
      sum[cur] = 0;
    if (l != r) {
      lzy[cur * 2] += lzy[cur];
      lzy[cur * 2 + 1] += lzy[cur];
    }
    lzy[cur] = 0;
  }
}
void build(int cur, int l, int r) {
  if (l == r) {
    cnt[cur] = sum[cur] = 1;
    return;
  }
  int mid = (l + r) >> 1;
  build(cur * 2, l, mid);
  build(cur * 2 + 1, mid + 1, r);
  mn[cur] = min(mn[cur * 2], mn[cur * 2 + 1]);
  cnt[cur] = (mn[cur] == mn[cur * 2]) * cnt[cur * 2] +
             (mn[cur] == mn[cur * 2 + 1]) * cnt[cur * 2 + 1];
  sum[cur] = (mn[cur * 2] == 0) * sum[cur * 2] +
             (mn[cur * 2 + 1] == 0) * sum[cur * 2 + 1];
}
void update(int cur, int l, int r, int L, int R, int val) {
  propagate(cur, l, r);
  if (l > R || r < L) return;
  if (l >= L && r <= R) {
    lzy[cur] += val;
    propagate(cur, l, r);
    return;
  }
  int mid = (l + r) >> 1;
  update(cur * 2, l, mid, L, R, val);
  update(cur * 2 + 1, mid + 1, r, L, R, val);
  mn[cur] = min(mn[cur * 2], mn[cur * 2 + 1]);
  cnt[cur] = (mn[cur] == mn[cur * 2]) * cnt[cur * 2] +
             (mn[cur] == mn[cur * 2 + 1]) * cnt[cur * 2 + 1];
  sum[cur] = (mn[cur * 2] == 0) * sum[cur * 2] +
             (mn[cur * 2 + 1] == 0) * sum[cur * 2 + 1];
}
void DFS(int u, int p) {
  for (auto x : q[u]) update(1, 1, n, st[x], en[x], +1);
  if (q[u].size()) update(1, 1, n, st[u], en[u], +1);
  Ans[u] = max(0, n - sum[1] - 1);
  for (int v : adj[u])
    if (v != p) DFS(v, u);
  for (auto x : q[u]) update(1, 1, n, st[x], en[x], -1);
  if (q[u].size()) update(1, 1, n, st[u], en[u], -1);
}
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int m;
  cin >> n >> m;
  build(1, 1, n);
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 0);
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    q[u].push_back(v);
    q[v].push_back(u);
  }
  DFS(1, 0);
  for (int i = 1; i <= n; i++) cout << Ans[i] << " ";
}
