#include <bits/stdc++.h>
using namespace std;
const int maxn = 100050;
int s[maxn];
int e[maxn];
vector<int> edge[maxn];
vector<int> que[maxn];
struct seg_node {
  int l, r;
  int cnt;
  int down;
  int len() { return r - l + 1; }
} S[maxn << 2];
int tot;
int ans[maxn];
int n, m;
void build(int l, int r, int root = 1) {
  S[root].l = l;
  S[root].r = r;
  S[root].cnt = S[root].down = 0;
  if (l == r) return;
  int mid = l + r >> 1;
  build(l, mid, (root << 1));
  build(mid + 1, r, (root << 1 | 1));
}
void push_up(int root) {
  if (S[root].down != 0)
    S[root].cnt = S[root].len();
  else {
    if (S[root].l == S[root].r)
      S[root].cnt = 0;
    else
      S[root].cnt = S[(root << 1)].cnt + S[(root << 1 | 1)].cnt;
  }
}
void update(int l, int r, int v, int rt) {
  if (S[rt].l == l && S[rt].r == r) {
    S[rt].down += v;
    push_up(rt);
    return;
  }
  int mid = S[rt].l + S[rt].r >> 1;
  if (r <= mid)
    update(l, r, v, (rt << 1));
  else if (l > mid)
    update(l, r, v, (rt << 1 | 1));
  else {
    update(l, mid, v, (rt << 1));
    update(mid + 1, r, v, (rt << 1 | 1));
  }
  push_up(rt);
}
void dfs(int u, int fa) {
  s[u] = ++tot;
  int esz = edge[u].size();
  for (int i = 0; i < esz; i++) {
    int v = edge[u][i];
    if (v != fa) dfs(v, u);
  }
  e[u] = tot;
}
void print() {
  for (int i = 1; i < n; i++) {
    printf("%d ", ans[i]);
  }
  printf("%d\n", ans[n]);
}
void init() {
  for (int i = 0; i <= n; i++) {
    edge[i].clear();
    que[i].clear();
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    que[a].push_back(b);
    que[a].push_back(a);
    que[b].push_back(a);
    que[b].push_back(b);
  }
  tot = 0;
  dfs(1, -1);
  build(1, n, 1);
}
void solve(int r = 1, int pre = -1) {
  for (int i = 0; i < que[r].size(); i++) {
    int v = que[r][i];
    update(s[v], e[v], 1, 1);
  }
  ans[r] = S[1].cnt;
  if (ans[r]) ans[r] -= 1;
  for (int i = 0; i < edge[r].size(); i++) {
    int v = edge[r][i];
    if (v != pre) solve(v, r);
  }
  for (int i = 0; i < que[r].size(); i++) {
    int v = que[r][i];
    update(s[v], e[v], -1, 1);
  }
}
using namespace std;
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    init();
    solve();
    print();
  }
  return 0;
}

### Prompt

Construct a cpp code solution to the problem outlined:

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 = 100050;
int s[maxn];
int e[maxn];
vector<int> edge[maxn];
vector<int> que[maxn];
struct seg_node {
  int l, r;
  int cnt;
  int down;
  int len() { return r - l + 1; }
} S[maxn << 2];
int tot;
int ans[maxn];
int n, m;
void build(int l, int r, int root = 1) {
  S[root].l = l;
  S[root].r = r;
  S[root].cnt = S[root].down = 0;
  if (l == r) return;
  int mid = l + r >> 1;
  build(l, mid, (root << 1));
  build(mid + 1, r, (root << 1 | 1));
}
void push_up(int root) {
  if (S[root].down != 0)
    S[root].cnt = S[root].len();
  else {
    if (S[root].l == S[root].r)
      S[root].cnt = 0;
    else
      S[root].cnt = S[(root << 1)].cnt + S[(root << 1 | 1)].cnt;
  }
}
void update(int l, int r, int v, int rt) {
  if (S[rt].l == l && S[rt].r == r) {
    S[rt].down += v;
    push_up(rt);
    return;
  }
  int mid = S[rt].l + S[rt].r >> 1;
  if (r <= mid)
    update(l, r, v, (rt << 1));
  else if (l > mid)
    update(l, r, v, (rt << 1 | 1));
  else {
    update(l, mid, v, (rt << 1));
    update(mid + 1, r, v, (rt << 1 | 1));
  }
  push_up(rt);
}
void dfs(int u, int fa) {
  s[u] = ++tot;
  int esz = edge[u].size();
  for (int i = 0; i < esz; i++) {
    int v = edge[u][i];
    if (v != fa) dfs(v, u);
  }
  e[u] = tot;
}
void print() {
  for (int i = 1; i < n; i++) {
    printf("%d ", ans[i]);
  }
  printf("%d\n", ans[n]);
}
void init() {
  for (int i = 0; i <= n; i++) {
    edge[i].clear();
    que[i].clear();
  }
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    que[a].push_back(b);
    que[a].push_back(a);
    que[b].push_back(a);
    que[b].push_back(b);
  }
  tot = 0;
  dfs(1, -1);
  build(1, n, 1);
}
void solve(int r = 1, int pre = -1) {
  for (int i = 0; i < que[r].size(); i++) {
    int v = que[r][i];
    update(s[v], e[v], 1, 1);
  }
  ans[r] = S[1].cnt;
  if (ans[r]) ans[r] -= 1;
  for (int i = 0; i < edge[r].size(); i++) {
    int v = edge[r][i];
    if (v != pre) solve(v, r);
  }
  for (int i = 0; i < que[r].size(); i++) {
    int v = que[r][i];
    update(s[v], e[v], -1, 1);
  }
}
using namespace std;
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    init();
    solve();
    print();
  }
  return 0;
}

```