#include <bits/stdc++.h>
using namespace std;
inline long long getint() {
  long long ssum = 0, ff = 1;
  char ch;
  for (ch = getchar(); !isdigit(ch) && ch != '-'; ch = getchar())
    ;
  if (ch == '-') ff = -1, ch = getchar();
  for (; isdigit(ch); ch = getchar()) ssum = ssum * 10 + ch - '0';
  return ssum * ff;
}
const long long M = 1e6 + 5;
long long etot, head[M], tot, go[M], nex[M], dfn[M], out[M], n, m, ans[M];
vector<long long> vec[M];
vector<long long>::iterator it;
struct SegMentTree {
  long long mi[M], cnt[M], tag[M];
  inline void Pushup(long long k) {
    mi[k] = min(mi[k << 1], mi[k << 1 | 1]);
    cnt[k] = 0;
    if (mi[k] == mi[k << 1]) cnt[k] += cnt[k << 1];
    if (mi[k] == mi[k << 1 | 1]) cnt[k] += cnt[k << 1 | 1];
  }
  inline void Pushdown(long long k) {
    if (!tag[k]) return;
    mi[k << 1] += tag[k];
    mi[k << 1 | 1] += tag[k];
    tag[k << 1] += tag[k];
    tag[k << 1 | 1] += tag[k];
    tag[k] = 0;
  }
  void Build(long long k, long long l, long long r) {
    if (l == r) {
      mi[k] = 0;
      cnt[k] = 1;
      return;
    }
    long long mid = l + r >> 1;
    Build(k << 1, l, mid);
    Build(k << 1 | 1, mid + 1, r);
    Pushup(k);
  }
  void Modify(long long k, long long l, long long r, long long x, long long y,
              long long val) {
    if (x > y) return;
    if (l >= x && r <= y) {
      mi[k] += val;
      tag[k] += val;
      return;
    }
    Pushdown(k);
    long long mid = l + r >> 1;
    if (x <= mid) Modify(k << 1, l, mid, x, y, val);
    if (y > mid) Modify(k << 1 | 1, mid + 1, r, x, y, val);
    Pushup(k);
  }
  long long Qu(long long k, long long l, long long r, long long x,
               long long y) {
    if (l >= x && r <= y) return (mi[k] == 0) ? cnt[k] : 0;
  }
} Tr;
inline void Addedge(long long u, long long v) {
  nex[++etot] = head[u];
  head[u] = etot;
  go[etot] = v;
}
void dfsdfn(long long u, long long fa) {
  dfn[u] = ++tot;
  for (long long i = head[u]; i; i = nex[i]) {
    long long v = go[i];
    if (v == fa) continue;
    dfsdfn(v, u);
  }
  out[u] = tot;
}
void dfs(long long u, long long fa) {
  for (it = vec[u].begin(); it != vec[u].end(); it++) {
    Tr.Modify(1, 1, n, dfn[u], out[u], 1);
    Tr.Modify(1, 1, n, dfn[*it], out[*it], 1);
  }
  ans[u] = n - Tr.Qu(1, 1, n, 1, n);
  for (long long i = head[u]; i; i = nex[i]) {
    long long v = go[i];
    if (v == fa) continue;
    dfs(v, u);
  }
  for (it = vec[u].begin(); it != vec[u].end(); it++) {
    Tr.Modify(1, 1, n, dfn[u], out[u], -1);
    Tr.Modify(1, 1, n, dfn[*it], out[*it], -1);
  }
}
signed main() {
  cin >> n >> m;
  for (long long i = 1, u, v; i < n; i++) {
    u = getint();
    v = getint();
    Addedge(u, v);
    Addedge(v, u);
  }
  while (m--) {
    long long x = getint(), y = getint();
    vec[x].push_back(y);
    vec[y].push_back(x);
  }
  dfsdfn(1, 0);
  Tr.Build(1, 1, n);
  dfs(1, 0);
  for (long long i = 1; i <= n; i++) cout << max(0ll, ans[i] - 1) << ' ';
  return 0;
}

### Prompt

Please formulate a cpp solution to the following problem:

The Little Elephant loves trees very much, he especially loves root trees.

He's got a tree consisting of n nodes (the nodes are numbered from 1 to n), with root at node number 1. Each node of the tree contains some list of numbers which initially is empty. 

The Little Elephant wants to apply m operations. On the i-th operation (1 ≤ i ≤ m) he first adds number i to lists of all nodes of a subtree with the root in node number ai, and then he adds number i to lists of all nodes of the subtree with root in node bi.

After applying all operations the Little Elephant wants to count for each node i number ci — the number of integers j (1 ≤ j ≤ n; j ≠ i), such that the lists of the i-th and the j-th nodes contain at least one common number.

Help the Little Elephant, count numbers ci for him.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 105) — the number of the tree nodes and the number of operations. 

Each of the following n - 1 lines contains two space-separated integers, ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi), that mean that there is an edge between nodes number ui and vi. 

Each of the following m lines contains two space-separated integers, ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi), that stand for the indexes of the nodes in the i-th operation.

It is guaranteed that the given graph is an undirected tree.

Output

In a single line print n space-separated integers — c1, c2, ..., cn.

Examples

Input

5 1
1 2
1 3
3 5
3 4
2 3


Output

0 3 3 3 3 

Input

11 3
1 2
2 3
2 4
1 5
5 6
5 7
5 8
6 9
8 10
8 11
2 9
3 6
2 8


Output

0 6 7 6 0 2 0 5 4 5 5 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
inline long long getint() {
  long long ssum = 0, ff = 1;
  char ch;
  for (ch = getchar(); !isdigit(ch) && ch != '-'; ch = getchar())
    ;
  if (ch == '-') ff = -1, ch = getchar();
  for (; isdigit(ch); ch = getchar()) ssum = ssum * 10 + ch - '0';
  return ssum * ff;
}
const long long M = 1e6 + 5;
long long etot, head[M], tot, go[M], nex[M], dfn[M], out[M], n, m, ans[M];
vector<long long> vec[M];
vector<long long>::iterator it;
struct SegMentTree {
  long long mi[M], cnt[M], tag[M];
  inline void Pushup(long long k) {
    mi[k] = min(mi[k << 1], mi[k << 1 | 1]);
    cnt[k] = 0;
    if (mi[k] == mi[k << 1]) cnt[k] += cnt[k << 1];
    if (mi[k] == mi[k << 1 | 1]) cnt[k] += cnt[k << 1 | 1];
  }
  inline void Pushdown(long long k) {
    if (!tag[k]) return;
    mi[k << 1] += tag[k];
    mi[k << 1 | 1] += tag[k];
    tag[k << 1] += tag[k];
    tag[k << 1 | 1] += tag[k];
    tag[k] = 0;
  }
  void Build(long long k, long long l, long long r) {
    if (l == r) {
      mi[k] = 0;
      cnt[k] = 1;
      return;
    }
    long long mid = l + r >> 1;
    Build(k << 1, l, mid);
    Build(k << 1 | 1, mid + 1, r);
    Pushup(k);
  }
  void Modify(long long k, long long l, long long r, long long x, long long y,
              long long val) {
    if (x > y) return;
    if (l >= x && r <= y) {
      mi[k] += val;
      tag[k] += val;
      return;
    }
    Pushdown(k);
    long long mid = l + r >> 1;
    if (x <= mid) Modify(k << 1, l, mid, x, y, val);
    if (y > mid) Modify(k << 1 | 1, mid + 1, r, x, y, val);
    Pushup(k);
  }
  long long Qu(long long k, long long l, long long r, long long x,
               long long y) {
    if (l >= x && r <= y) return (mi[k] == 0) ? cnt[k] : 0;
  }
} Tr;
inline void Addedge(long long u, long long v) {
  nex[++etot] = head[u];
  head[u] = etot;
  go[etot] = v;
}
void dfsdfn(long long u, long long fa) {
  dfn[u] = ++tot;
  for (long long i = head[u]; i; i = nex[i]) {
    long long v = go[i];
    if (v == fa) continue;
    dfsdfn(v, u);
  }
  out[u] = tot;
}
void dfs(long long u, long long fa) {
  for (it = vec[u].begin(); it != vec[u].end(); it++) {
    Tr.Modify(1, 1, n, dfn[u], out[u], 1);
    Tr.Modify(1, 1, n, dfn[*it], out[*it], 1);
  }
  ans[u] = n - Tr.Qu(1, 1, n, 1, n);
  for (long long i = head[u]; i; i = nex[i]) {
    long long v = go[i];
    if (v == fa) continue;
    dfs(v, u);
  }
  for (it = vec[u].begin(); it != vec[u].end(); it++) {
    Tr.Modify(1, 1, n, dfn[u], out[u], -1);
    Tr.Modify(1, 1, n, dfn[*it], out[*it], -1);
  }
}
signed main() {
  cin >> n >> m;
  for (long long i = 1, u, v; i < n; i++) {
    u = getint();
    v = getint();
    Addedge(u, v);
    Addedge(v, u);
  }
  while (m--) {
    long long x = getint(), y = getint();
    vec[x].push_back(y);
    vec[y].push_back(x);
  }
  dfsdfn(1, 0);
  Tr.Build(1, 1, n);
  dfs(1, 0);
  for (long long i = 1; i <= n; i++) cout << max(0ll, ans[i] - 1) << ' ';
  return 0;
}

```