#include <bits/stdc++.h>
using namespace std;
int dtime[100005], lim[100005][2], tree[400005][3], nxt = 1, cnt[100005], n, m,
                                                    out[100005];
vector<int> vec[100005], qr[100005];
void dfs(int node, int parent) {
  dtime[node] = nxt;
  lim[node][0] = nxt;
  nxt++;
  int i, j, k, x = -1, y = 0;
  for (i = 0; i < vec[node].size(); i++) {
    j = vec[node][i];
    if (j == parent) continue;
    dfs(j, node);
  }
  lim[node][1] = nxt - 1;
  return;
}
void build(int node, int l, int r) {
  if (l == r) {
    tree[node][1] = tree[node][2] = 0;
    tree[node][0] = 1;
    return;
  }
  int ln = node * 2;
  int mid = (l + r) / 2;
  build(ln, l, mid);
  build(ln + 1, mid + 1, r);
  tree[node][0] = r - l + 1;
  return;
}
void up(int node, int l, int r, int i, int j, int x) {
  if (l > j || r < i) return;
  if (l >= i && r <= j) {
    tree[node][2] += x;
    return;
  }
  int ln = node * 2, mid = (l + r) / 2;
  tree[ln][2] += tree[node][2];
  tree[ln + 1][2] += tree[node][2];
  tree[node][2] = 0;
  up(ln, l, mid, i, j, x);
  up(ln + 1, mid + 1, r, i, j, x);
  tree[node][1] =
      min((tree[ln][1] + tree[ln][2]), (tree[ln + 1][2] + tree[ln + 1][1]));
  tree[node][0] =
      (tree[ln][1] + tree[ln][2] == tree[node][1] ? tree[ln][0] : 0) +
      (tree[ln + 1][1] + tree[ln + 1][2] == tree[node][1] ? tree[ln + 1][0]
                                                          : 0);
  return;
}
void op(int node, int parent) {
  int i, j, k, x, y, z;
  if (qr[node].size() > 0) {
    up(1, 1, n + 1, lim[node][0], lim[node][1], 1);
  }
  for (i = 0; i < qr[node].size(); i++) {
    x = qr[node][i];
    up(1, 1, n + 1, lim[x][0], lim[x][1], 1);
  }
  if (tree[1][1] == n) {
    out[node] = n - 1;
  } else {
    out[node] = max(n - tree[1][0], 0);
  }
  for (i = 0; i < vec[node].size(); i++) {
    j = vec[node][i];
    if (j == parent) continue;
    op(j, node);
  }
  for (i = 0; i < qr[node].size(); i++) {
    x = qr[node][i];
    up(1, 1, n + 1, lim[x][0], lim[x][1], -1);
  }
  if (qr[node].size() > 0) {
    up(1, 1, n + 1, lim[node][0], lim[node][1], -1);
  }
  return;
}
int main() {
  int i, j, k, a, b, c, x, y, z;
  cin >> n >> m;
  for (i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  dfs(1, -1);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    qr[a].push_back(b);
    qr[b].push_back(a);
  }
  build(1, 1, n + 1);
  op(1, -1);
  for (i = 1; i <= n; i++) {
    printf("%d ", out[i]);
  }
  cout << endl;
}
