#include <bits/stdc++.h>
using namespace std;
long long int powmod(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
int l[int(1e5 + 10)], r[int(1e5 + 10)], a[int(1e5 + 10)], b[int(1e5 + 10)],
    aa[int(1e5 + 10)], n, c[int(1e5 + 10)];
vector<int> edge[int(1e5 + 10)];
vector<int> v[int(1e5 + 10)];
int sz[int(1e5 + 10)] = {0}, t = 0, seg[4 * int(1e5 + 10)] = {0},
                 sum[4 * int(1e5 + 10)] = {0}, sz2[int(1e5 + 10)] = {0};
void dfs(int vertex, int parent) {
  aa[++t] = vertex;
  l[vertex] = t;
  for (int i = 0; i < sz[vertex]; ++i) {
    if (edge[vertex][i] != parent) {
      dfs(edge[vertex][i], vertex);
    }
  }
  r[vertex] = t;
}
void update(int n, int it, int f, int q1, int q2, int val) {
  if (it == q1 && f == q2) {
    seg[n] += val;
    if (seg[n] > 0)
      sum[n] = f - it + 1;
    else {
      if (it == f)
        sum[n] = 0;
      else
        sum[n] = sum[n * 2] + sum[n * 2 + 1];
    }
    return;
  }
  int m = (it + f) / 2;
  if (q2 <= m)
    update(n * 2, it, m, q1, q2, val);
  else if (q1 > m)
    update(n * 2 + 1, m + 1, f, q1, q2, val);
  else {
    update(n * 2, it, m, q1, m, val);
    update(n * 2 + 1, m + 1, f, m + 1, q2, val);
  }
  if (seg[n] > 0)
    sum[n] = f - it + 1;
  else
    sum[n] = sum[n * 2] + sum[n * 2 + 1];
}
void dfs2(int vertex, int parent) {
  for (int i = 0; i < sz2[vertex]; ++i) {
    int clr = v[vertex][i];
    update(1, 1, n, l[a[clr]], r[a[clr]], +1);
    update(1, 1, n, l[b[clr]], r[b[clr]], +1);
  }
  c[vertex] = max(0, sum[1] - 1);
  for (int i = 0; i < sz[vertex]; ++i) {
    if (edge[vertex][i] != parent) {
      dfs2(edge[vertex][i], vertex);
    }
  }
  for (int i = 0; i < sz2[vertex]; ++i) {
    int clr = v[vertex][i];
    update(1, 1, n, l[a[clr]], r[a[clr]], -1);
    update(1, 1, n, l[b[clr]], r[b[clr]], -1);
  }
}
int main() {
  int m, u, v2;
  cin >> n >> m;
  for (int i = int(1); i <= (int)n - 1; i++) {
    scanf("%d", &u);
    ;
    scanf("%d", &v2);
    ;
    edge[u].push_back(v2);
    edge[v2].push_back(u);
    sz[u]++;
    sz[v2]++;
  }
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &a[i]);
    ;
    scanf("%d", &b[i]);
    ;
    v[a[i]].push_back(i);
    v[b[i]].push_back(i);
    sz2[a[i]]++;
    sz2[b[i]]++;
  }
  dfs(1, -1);
  dfs2(1, -1);
  for (int i = int(1); i <= (int)n; i++) printf("%d ", c[i]);
  printf("\n");
  return 0;
}
