#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int n, n2 = 1, m, st[100010], ed[100010], dat[10000000], ls[10000000],
       rs[10000000], ans[100010], len;
vector<int> g[100010], v[100010];
void dfs(int pos, int no) {
  st[pos] = len++;
  for (int i = 0; i < g[pos].size(); i++)
    if (g[pos][i] != no) dfs(g[pos][i], pos);
  ed[pos] = len - 1;
}
void build(int k, int lb, int ub) {
  len = max(len, k);
  if (lb == ub) return;
  ls[k] = k * 2 + 1;
  rs[k] = k * 2 + 2;
  build(ls[k], lb, (lb + ub) / 2);
  build(rs[k], (lb + ub) / 2 + 1, ub);
}
int upd(int k, int lb, int ub, int tlb, int tub) {
  if (ub < tlb || tub < lb || dat[k] == ub - lb + 1) return k;
  int kk = ++len;
  dat[kk] = dat[k];
  ls[kk] = ls[k];
  rs[kk] = rs[k];
  if (tlb <= lb && ub <= tub) {
    dat[kk] = ub - lb + 1;
    return kk;
  }
  ls[kk] = upd(ls[kk], lb, (lb + ub) / 2, tlb, tub);
  rs[kk] = upd(rs[kk], (lb + ub) / 2 + 1, ub, tlb, tub);
  dat[kk] = dat[ls[kk]] + dat[rs[kk]];
  return kk;
}
void dfs2(int pos, int no, int root) {
  for (int i = 0; i < v[pos].size(); i++)
    root = upd(root, 0, n2 - 1, st[v[pos][i]], ed[v[pos][i]]);
  ans[pos] = dat[root] - (dat[root] > 0 ? 1 : 0);
  for (int i = 0; i < g[pos].size(); i++)
    if (g[pos][i] != no) dfs2(g[pos][i], pos, root);
}
int main() {
  cin >> n >> m;
  int x, y;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    v[x].push_back(x);
    v[x].push_back(y);
    v[y].push_back(x);
    v[y].push_back(y);
  }
  for (int i = 1; i <= n; i++) {
    sort(v[i].begin(), v[i].end());
    v[i].erase(unique(v[i].begin(), v[i].end()), v[i].end());
  }
  dfs(1, 0);
  while (n2 < n) n2 *= 2;
  for (int i = 0; i < 9999995; i++) ls[i] = rs[i] = -1;
  len = 0;
  build(0, 0, n2 - 1);
  dfs2(1, 0, 0);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  cout << endl;
  return 0;
}
