#include <bits/stdc++.h>
using namespace std;
long long convertToNum(string s) {
  long long val = 0;
  for (int i = 0; i < (s.size()); i++) val = val * 10 + s[i] - '0';
  return val;
}
char bu[50];
string convertToString(int a) {
  sprintf(bu, "%d", a);
  return string(bu);
}
long long GCD(long long x, long long y) {
  if (!x) return y;
  if (!y) return x;
  if (x == y) return x;
  if (x < y)
    return GCD(x, y % x);
  else
    return GCD(x % y, y);
}
long long POW(long long x, long long y, long long Base) {
  if (!y) return 1;
  long long u = POW(x, y / 2, Base);
  u = (u * u) % Base;
  if (y & 1)
    return (u * x) % Base;
  else
    return u;
}
void extended_euclid(long long A, long long B, long long &x, long long &y) {
  if (A == 1 && B == 0) {
    x = 1;
    y = 0;
    return;
  }
  if (A < B)
    extended_euclid(B, A, y, x);
  else {
    long long xx, yy;
    extended_euclid(A % B, B, xx, yy);
    x = xx;
    y = yy - (A / B) * xx;
  }
}
void OPEN() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}
int n, m;
vector<int> a[100100], Query[100100];
int ds[100100], st[100100], fn[100100];
int cnt;
int kq[100100];
int nChild[100100];
int Tree[100100 * 8];
int sl[100100 * 8];
void update(int node, int first, int last, int dau, int cuoi, int val) {
  if (last < dau || cuoi < first) return;
  if (dau <= first && last <= cuoi) {
    Tree[node] += val;
    if (Tree[node])
      sl[node] = last - first + 1;
    else
      sl[node] = sl[node * 2] + sl[node * 2 + 1];
    return;
  }
  int mid = (first + last) >> 1;
  update(node << 1, first, mid, dau, cuoi, val);
  update((node << 1) + 1, mid + 1, last, dau, cuoi, val);
  if (Tree[node])
    sl[node] = last - first + 1;
  else
    sl[node] = sl[node * 2] + sl[node * 2 + 1];
}
void solve(int u, int par) {
  if (Query[u].size()) update(1, 1, n, st[u], fn[u], 1);
  for (int i = 0; i < (Query[u].size()); i++) {
    int v = Query[u][i];
    update(1, 1, n, st[v], fn[v], 1);
  }
  kq[u] = max(0, sl[1] - 1);
  for (int i = 0; i < (a[u].size()); i++) {
    int v = a[u][i];
    if (v == par) continue;
    solve(v, u);
  }
  if (Query[u].size()) update(1, 1, n, st[u], fn[u], -1);
  for (int i = 0; i < (Query[u].size()); i++) {
    int v = Query[u][i];
    update(1, 1, n, st[v], fn[v], -1);
  }
}
void dfs(int u, int par) {
  cnt++;
  ds[cnt] = u;
  st[u] = cnt;
  nChild[u]++;
  for (int i = 0; i < (a[u].size()); i++) {
    int v = a[u][i];
    if (v == par) continue;
    dfs(v, u);
    nChild[u] += nChild[v];
  }
  fn[u] = cnt;
}
int main() {
  scanf("%d%d", &n, &m);
  int u, v;
  for (int i = (1); i <= (n - 1); i++) {
    scanf("%d%d", &u, &v);
    a[u].push_back(v);
    a[v].push_back(u);
  }
  for (int i = (1); i <= (m); i++) {
    scanf("%d%d", &u, &v);
    Query[u].push_back(v);
    Query[v].push_back(u);
  }
  dfs(1, 1);
  solve(1, 1);
  for (int i = (1); i <= (n); i++) printf("%d ", kq[i]);
  return 0;
}
