#include <bits/stdc++.h>
using namespace std;
int vv[200007 * 2], nxt[200007 * 2], h[200007], e;
int L[200007], R[200007], deep, pos[200007];
int ans[200007], a[200007], b[200007];
int n, m;
struct Node {
  int l, r, max, flag;
} nde[200007 * 4];
struct Pos {
  int pos, id;
  void init(int a, int b) {
    pos = a;
    id = b;
  };
} p[200007 * 4];
bool cmp(Pos a, Pos b) {
  return a.pos < b.pos || a.pos == b.pos && a.id < b.id;
}
void add(int u, int v) {
  vv[e] = v;
  nxt[e] = h[u];
  h[u] = e++;
  vv[e] = u;
  nxt[e] = h[v];
  h[v] = e++;
}
void dfs(int u, int fa) {
  L[u] = ++deep;
  pos[deep] = u;
  for (int i = h[u]; i + 1; i = nxt[i])
    if (vv[i] != fa) dfs(vv[i], u);
  R[u] = deep;
}
void build(int l, int r, int p) {
  nde[p].l = l;
  nde[p].r = r;
  nde[p].max = nde[p].flag = 0;
  if (l == r) {
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, p * 2);
  build(mid + 1, r, p * 2 + 1);
}
void pushdown(int p) {
  int ls = p << 1, rs = ls | 1;
  if (nde[p].flag) {
    nde[ls].max = nde[ls].r - nde[ls].l + 1;
    nde[ls].flag += nde[p].flag;
    nde[rs].max = nde[rs].r - nde[rs].l + 1;
    nde[rs].flag += nde[p].flag;
    nde[p].flag = 0;
  }
}
void update(int l, int r, int p, int flag) {
  if (l <= nde[p].l && r >= nde[p].r) {
    nde[p].flag += flag;
    if (nde[p].flag)
      nde[p].max = nde[p].r - nde[p].l + 1;
    else {
      nde[p].max = nde[p << 1].max + nde[p << 1 | 1].max;
    }
    return;
  }
  if (l > nde[p].r || r < nde[p].l) return;
  update(l, r, p << 1, flag);
  update(l, r, p << 1 | 1, flag);
  if (nde[p].flag <= 0) nde[p].max = nde[p << 1].max + nde[p << 1 | 1].max;
}
int main() {
  int u, v, num = 0;
  memset(h, -1, sizeof(h));
  deep = e = 0;
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &u, &v);
    add(u, v);
  }
  dfs(1, -1);
  build(1, n, 1);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &a[i], &b[i]);
    p[num++].init(L[a[i]], i << 1);
    p[num++].init(R[a[i]] + 1, i << 1 | 1);
    p[num++].init(L[b[i]], i << 1);
    p[num++].init(R[b[i]] + 1, i << 1 | 1);
  }
  sort(p, p + num, cmp);
  int j = 0;
  for (int i = 1; i <= n; i++) {
    while (j < num && p[j].pos == i) {
      int id = p[j].id >> 1;
      int flag = p[j].id & 1 ? -1 : 1;
      update(L[a[id]], R[a[id]], 1, flag);
      update(L[b[id]], R[b[id]], 1, flag);
      j++;
    }
    ans[pos[i]] = max(nde[1].max - 1, 0);
  }
  for (int i = 1; i <= n; i++) {
    printf("%d", ans[i]);
    if (i == n)
      printf("\n");
    else
      printf(" ");
  }
}
