#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 1000 + 10;
vector<long long> graph[MAXN], vec[MAXN];
bool mark[MAXN];
pair<long long, long long> seg[MAXN * 4];
long long st[MAXN], fi[MAXN], ans[MAXN];
long long n, m;
void add(int l, int r, long long x, int v = 1, long long second = 0,
         long long e = n) {
  if (e <= l || r <= second) return;
  if (l <= second && e <= r) {
    seg[v].second += x;
    if (seg[v].second > 0) seg[v].first = e - second;
    if (seg[v].second == 0)
      seg[v].first = seg[v * 2].first + seg[v * 2 + 1].first;
    return;
  }
  int m = (second + e) / 2;
  add(l, r, x, v * 2, second, m);
  add(l, r, x, v * 2 + 1, m, e);
  if (seg[v].second == 0)
    seg[v].first = seg[v * 2].first + seg[v * 2 + 1].first;
}
void dfs(int v) {
  for (int i = 0; i < (int)vec[v].size(); i++)
    add(st[vec[v][i]], fi[vec[v][i]], 1);
  if ((int)vec[v].size()) add(st[v], fi[v], 1);
  ans[v] = seg[1].first;
  if (ans[v] != 0) ans[v]--;
  mark[v] = true;
  for (int i = 0; i < (int)graph[v].size(); i++)
    if (!mark[graph[v][i]]) dfs(graph[v][i]);
  for (int i = 0; i < (int)vec[v].size(); i++)
    add(st[vec[v][i]], fi[vec[v][i]], -1);
  if ((int)vec[v].size()) add(st[v], fi[v], -1);
}
long long tme = 0;
void p_dfs(int v) {
  mark[v] = true;
  st[v] = tme++;
  for (int i = 0; i < (int)graph[v].size(); i++)
    if (!mark[graph[v][i]]) p_dfs(graph[v][i]);
  fi[v] = tme;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  p_dfs(0);
  for (int i = 0; i < n; i++) mark[i] = false;
  dfs(0);
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
}

### Prompt

In Cpp, your task is to solve 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 = 1000 * 1000 + 10;
vector<long long> graph[MAXN], vec[MAXN];
bool mark[MAXN];
pair<long long, long long> seg[MAXN * 4];
long long st[MAXN], fi[MAXN], ans[MAXN];
long long n, m;
void add(int l, int r, long long x, int v = 1, long long second = 0,
         long long e = n) {
  if (e <= l || r <= second) return;
  if (l <= second && e <= r) {
    seg[v].second += x;
    if (seg[v].second > 0) seg[v].first = e - second;
    if (seg[v].second == 0)
      seg[v].first = seg[v * 2].first + seg[v * 2 + 1].first;
    return;
  }
  int m = (second + e) / 2;
  add(l, r, x, v * 2, second, m);
  add(l, r, x, v * 2 + 1, m, e);
  if (seg[v].second == 0)
    seg[v].first = seg[v * 2].first + seg[v * 2 + 1].first;
}
void dfs(int v) {
  for (int i = 0; i < (int)vec[v].size(); i++)
    add(st[vec[v][i]], fi[vec[v][i]], 1);
  if ((int)vec[v].size()) add(st[v], fi[v], 1);
  ans[v] = seg[1].first;
  if (ans[v] != 0) ans[v]--;
  mark[v] = true;
  for (int i = 0; i < (int)graph[v].size(); i++)
    if (!mark[graph[v][i]]) dfs(graph[v][i]);
  for (int i = 0; i < (int)vec[v].size(); i++)
    add(st[vec[v][i]], fi[vec[v][i]], -1);
  if ((int)vec[v].size()) add(st[v], fi[v], -1);
}
long long tme = 0;
void p_dfs(int v) {
  mark[v] = true;
  st[v] = tme++;
  for (int i = 0; i < (int)graph[v].size(); i++)
    if (!mark[graph[v][i]]) p_dfs(graph[v][i]);
  fi[v] = tme;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  p_dfs(0);
  for (int i = 0; i < n; i++) mark[i] = false;
  dfs(0);
  for (int i = 0; i < n; i++) cout << ans[i] << " ";
  cout << endl;
}

```