#include <bits/stdc++.h>
using namespace std;
struct Edge {
  int to, next;
} edge[100100 << 1];
int head[100100], tot;
void addedge(int u, int v) {
  edge[tot].to = v;
  edge[tot].next = head[u];
  head[u] = tot++;
}
void init() {
  memset(head, -1, sizeof(head));
  tot = 0;
}
vector<pair<int, int> > op[100100];
int tim;
int in[100100], out[100100];
int n, m;
void dfs1(int u, int pre) {
  in[u] = ++tim;
  op[u].clear();
  for (int i = head[u]; ~i; i = edge[i].next) {
    int v = edge[i].to;
    if (v == pre) continue;
    dfs1(v, u);
  }
  out[u] = tim;
}
int ans[100100];
int mn[100100 << 2], addv[100100 << 2], sum[100100 << 2];
void maintain(int o, int l, int r, int val) {
  addv[o] += val;
  mn[o] += val;
  if (mn[o] > 0)
    sum[o] = r - l + 1;
  else if (l == r)
    sum[o] = 0;
  else
    sum[o] = sum[(o << 1)] + sum[((o << 1) | 1)];
}
void down(int o, int l, int r) {
  if (addv[o] != 0) {
    maintain((o << 1), l, ((l + r) >> 1), addv[o]);
    maintain(((o << 1) | 1), ((l + r) >> 1) + 1, r, addv[o]);
    addv[o] = 0;
  }
}
void up(int o) {
  mn[o] = min(mn[(o << 1)], mn[((o << 1) | 1)]);
  sum[o] = sum[(o << 1)] + sum[((o << 1) | 1)];
}
void update(int o, int l, int r, int y1, int y2, int val) {
  if (y1 <= l && y2 >= r) {
    maintain(o, l, r, val);
    return;
  }
  if (y1 <= ((l + r) >> 1)) update((o << 1), l, ((l + r) >> 1), y1, y2, val);
  if (y2 > ((l + r) >> 1))
    update(((o << 1) | 1), ((l + r) >> 1) + 1, r, y1, y2, val);
  maintain(o, l, r, 0);
}
void dfs2(int u, int pre) {
  for (int i = 0; i < op[u].size(); ++i)
    update(1, 1, n, op[u][i].first, op[u][i].second, 1);
  ans[u] = max(0, sum[1] - 1);
  for (int i = head[u]; ~i; i = edge[i].next) {
    int v = edge[i].to;
    if (v == pre) continue;
    dfs2(v, u);
  }
  for (int i = 0; i < op[u].size(); ++i)
    update(1, 1, n, op[u][i].first, op[u][i].second, -1);
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    init();
    int u, v;
    for (int i = 1; i < n; ++i) {
      scanf("%d%d", &u, &v);
      addedge(u, v);
      addedge(v, u);
    }
    tim = 0;
    dfs1(1, -1);
    while (m--) {
      scanf("%d%d", &u, &v);
      op[u].push_back(pair<int, int>(in[v], out[v]));
      op[u].push_back(pair<int, int>(in[u], out[u]));
      op[v].push_back(pair<int, int>(in[u], out[u]));
      op[v].push_back(pair<int, int>(in[v], out[v]));
    }
    memset(mn, 0, sizeof(mn));
    memset(ans, 0, sizeof(ans));
    memset(addv, 0, sizeof(addv));
    dfs2(1, -1);
    for (int i = 1; i <= n; ++i) printf("%d%c", ans[i], i == n ? '\n' : ' ');
  }
  return 0;
}

### Prompt

Your task is to create 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;
struct Edge {
  int to, next;
} edge[100100 << 1];
int head[100100], tot;
void addedge(int u, int v) {
  edge[tot].to = v;
  edge[tot].next = head[u];
  head[u] = tot++;
}
void init() {
  memset(head, -1, sizeof(head));
  tot = 0;
}
vector<pair<int, int> > op[100100];
int tim;
int in[100100], out[100100];
int n, m;
void dfs1(int u, int pre) {
  in[u] = ++tim;
  op[u].clear();
  for (int i = head[u]; ~i; i = edge[i].next) {
    int v = edge[i].to;
    if (v == pre) continue;
    dfs1(v, u);
  }
  out[u] = tim;
}
int ans[100100];
int mn[100100 << 2], addv[100100 << 2], sum[100100 << 2];
void maintain(int o, int l, int r, int val) {
  addv[o] += val;
  mn[o] += val;
  if (mn[o] > 0)
    sum[o] = r - l + 1;
  else if (l == r)
    sum[o] = 0;
  else
    sum[o] = sum[(o << 1)] + sum[((o << 1) | 1)];
}
void down(int o, int l, int r) {
  if (addv[o] != 0) {
    maintain((o << 1), l, ((l + r) >> 1), addv[o]);
    maintain(((o << 1) | 1), ((l + r) >> 1) + 1, r, addv[o]);
    addv[o] = 0;
  }
}
void up(int o) {
  mn[o] = min(mn[(o << 1)], mn[((o << 1) | 1)]);
  sum[o] = sum[(o << 1)] + sum[((o << 1) | 1)];
}
void update(int o, int l, int r, int y1, int y2, int val) {
  if (y1 <= l && y2 >= r) {
    maintain(o, l, r, val);
    return;
  }
  if (y1 <= ((l + r) >> 1)) update((o << 1), l, ((l + r) >> 1), y1, y2, val);
  if (y2 > ((l + r) >> 1))
    update(((o << 1) | 1), ((l + r) >> 1) + 1, r, y1, y2, val);
  maintain(o, l, r, 0);
}
void dfs2(int u, int pre) {
  for (int i = 0; i < op[u].size(); ++i)
    update(1, 1, n, op[u][i].first, op[u][i].second, 1);
  ans[u] = max(0, sum[1] - 1);
  for (int i = head[u]; ~i; i = edge[i].next) {
    int v = edge[i].to;
    if (v == pre) continue;
    dfs2(v, u);
  }
  for (int i = 0; i < op[u].size(); ++i)
    update(1, 1, n, op[u][i].first, op[u][i].second, -1);
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    init();
    int u, v;
    for (int i = 1; i < n; ++i) {
      scanf("%d%d", &u, &v);
      addedge(u, v);
      addedge(v, u);
    }
    tim = 0;
    dfs1(1, -1);
    while (m--) {
      scanf("%d%d", &u, &v);
      op[u].push_back(pair<int, int>(in[v], out[v]));
      op[u].push_back(pair<int, int>(in[u], out[u]));
      op[v].push_back(pair<int, int>(in[u], out[u]));
      op[v].push_back(pair<int, int>(in[v], out[v]));
    }
    memset(mn, 0, sizeof(mn));
    memset(ans, 0, sizeof(ans));
    memset(addv, 0, sizeof(addv));
    dfs2(1, -1);
    for (int i = 1; i <= n; ++i) printf("%d%c", ans[i], i == n ? '\n' : ' ');
  }
  return 0;
}

```