#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
vector<int> edge[maxn], adj[maxn];
int L[maxn], R[maxn], dfn;
int ans[maxn];
void dfs(int u, int fa) {
  L[u] = ++dfn;
  for (typeof(edge[u].begin()) it = edge[u].begin(); it != edge[u].end();
       it++) {
    if (*it != fa) dfs(*it, u);
  }
  R[u] = dfn;
}
int col[maxn << 2];
int sum[maxn << 2];
void pushup(int rt, int l, int r) {
  if (col[rt] > 0) {
    sum[rt] = r - l + 1;
  } else if (l == r) {
    sum[rt] = 0;
  } else {
    sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
  }
}
void update(int L, int R, int val, int l, int r, int rt) {
  if (L <= l && r <= R) {
    col[rt] += val;
    pushup(rt, l, r);
    return;
  }
  int m = l + r >> 1;
  if (L <= m) update(L, R, val, l, m, rt << 1);
  if (R > m) update(L, R, val, m + 1, r, rt << 1 | 1);
  pushup(rt, l, r);
}
void solve(int u, int fa) {
  for (typeof(adj[u].begin()) it = adj[u].begin(); it != adj[u].end(); it++) {
    update(L[*it], R[*it], 1, 1, dfn, 1);
  }
  ans[u] = sum[1];
  for (typeof(edge[u].begin()) it = edge[u].begin(); it != edge[u].end();
       it++) {
    if (*it != fa) solve(*it, u);
  }
  for (typeof(adj[u].begin()) it = adj[u].begin(); it != adj[u].end(); it++) {
    update(L[*it], R[*it], -1, 1, dfn, 1);
  }
}
int main() {
  int n, m, u, v, a, b;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n - 1; i++)
    scanf("%d%d", &u, &v), edge[u].push_back(v), edge[v].push_back(u);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    adj[a].push_back(a);
    adj[a].push_back(b);
    adj[b].push_back(a);
    adj[b].push_back(b);
  }
  dfs(1, -1);
  solve(1, -1);
  for (int i = 0; i < n; i++) printf("%d ", max(1, ans[i + 1]) - 1);
  return 0;
}

### Prompt

Generate 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;
const int maxn = 100010;
vector<int> edge[maxn], adj[maxn];
int L[maxn], R[maxn], dfn;
int ans[maxn];
void dfs(int u, int fa) {
  L[u] = ++dfn;
  for (typeof(edge[u].begin()) it = edge[u].begin(); it != edge[u].end();
       it++) {
    if (*it != fa) dfs(*it, u);
  }
  R[u] = dfn;
}
int col[maxn << 2];
int sum[maxn << 2];
void pushup(int rt, int l, int r) {
  if (col[rt] > 0) {
    sum[rt] = r - l + 1;
  } else if (l == r) {
    sum[rt] = 0;
  } else {
    sum[rt] = sum[rt << 1] + sum[rt << 1 | 1];
  }
}
void update(int L, int R, int val, int l, int r, int rt) {
  if (L <= l && r <= R) {
    col[rt] += val;
    pushup(rt, l, r);
    return;
  }
  int m = l + r >> 1;
  if (L <= m) update(L, R, val, l, m, rt << 1);
  if (R > m) update(L, R, val, m + 1, r, rt << 1 | 1);
  pushup(rt, l, r);
}
void solve(int u, int fa) {
  for (typeof(adj[u].begin()) it = adj[u].begin(); it != adj[u].end(); it++) {
    update(L[*it], R[*it], 1, 1, dfn, 1);
  }
  ans[u] = sum[1];
  for (typeof(edge[u].begin()) it = edge[u].begin(); it != edge[u].end();
       it++) {
    if (*it != fa) solve(*it, u);
  }
  for (typeof(adj[u].begin()) it = adj[u].begin(); it != adj[u].end(); it++) {
    update(L[*it], R[*it], -1, 1, dfn, 1);
  }
}
int main() {
  int n, m, u, v, a, b;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n - 1; i++)
    scanf("%d%d", &u, &v), edge[u].push_back(v), edge[v].push_back(u);
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    adj[a].push_back(a);
    adj[a].push_back(b);
    adj[b].push_back(a);
    adj[b].push_back(b);
  }
  dfs(1, -1);
  solve(1, -1);
  for (int i = 0; i < n; i++) printf("%d ", max(1, ans[i + 1]) - 1);
  return 0;
}

```