#include <bits/stdc++.h>
using namespace std;
struct SegTree {
  int N, n;
  vector<int> c, all;
  int ql, qr, d;
  void init(int n) {
    this->n = n;
    for (N = 1; N < n; N <<= 1)
      ;
    c = vector<int>(N * 2, 0);
    all = vector<int>(N * 2, 0);
  }
  void _update(int p, int pl, int pr) {
    if (ql <= pl && pr <= qr) {
      all[p] += d;
    } else {
      int pm = pl + (pr - pl) / 2;
      if (ql < pm) {
        _update(((p) << 1), pl, pm);
      }
      if (pm < qr) {
        _update((((p) << 1) | 1), pm, pr);
      }
    }
    if (pl + 1 == pr) {
      c[p] = !!all[p];
    } else if (all[p] == 0) {
      c[p] = c[((p) << 1)] + c[(((p) << 1) | 1)];
    } else {
      c[p] = pr - pl;
    }
  }
  void update(int ql, int qr, int d) {
    this->ql = ql;
    this->qr = qr;
    this->d = d;
    _update(1, 0, N);
  }
  int query() { return c[1]; }
} st;
const int MAXN = 100000;
const int MAXM = 100000;
int n, m, tot;
int order[MAXN];
int l[MAXN], r[MAXN];
vector<int> add[MAXN], sub[MAXN + 1];
int res[MAXN];
vector<int> e[MAXN];
int a[MAXM], b[MAXM];
void dfs(int u, int fa) {
  order[tot] = u;
  l[u] = tot++;
  for (vector<int>::const_iterator i = e[u].begin(); i != e[u].end(); ++i) {
    if (*i != fa) {
      dfs(*i, u);
    }
  }
  r[u] = tot;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u - 1].push_back(v - 1);
    e[v - 1].push_back(u - 1);
  }
  tot = 0;
  dfs(0, -1);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    --a[i];
    --b[i];
    add[l[a[i]]].push_back(i);
    add[l[b[i]]].push_back(i);
    sub[r[a[i]]].push_back(i);
    sub[r[b[i]]].push_back(i);
  }
  st.init(n);
  for (int i = 0; i < n; ++i) {
    for (vector<int>::const_iterator j = add[i].begin(); j != add[i].end();
         ++j) {
      st.update(l[a[*j]], r[a[*j]], 1);
      st.update(l[b[*j]], r[b[*j]], 1);
    }
    for (vector<int>::const_iterator j = sub[i].begin(); j != sub[i].end();
         ++j) {
      st.update(l[a[*j]], r[a[*j]], -1);
      st.update(l[b[*j]], r[b[*j]], -1);
    }
    res[order[i]] = st.query();
  }
  for (int i = 0; i < n; ++i) {
    printf("%d%c", res[i] == 0 ? 0 : res[i] - 1, i + 1 == n ? '\n' : ' ');
  }
  return 0;
}

### Prompt

Please create a solution in cpp 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 SegTree {
  int N, n;
  vector<int> c, all;
  int ql, qr, d;
  void init(int n) {
    this->n = n;
    for (N = 1; N < n; N <<= 1)
      ;
    c = vector<int>(N * 2, 0);
    all = vector<int>(N * 2, 0);
  }
  void _update(int p, int pl, int pr) {
    if (ql <= pl && pr <= qr) {
      all[p] += d;
    } else {
      int pm = pl + (pr - pl) / 2;
      if (ql < pm) {
        _update(((p) << 1), pl, pm);
      }
      if (pm < qr) {
        _update((((p) << 1) | 1), pm, pr);
      }
    }
    if (pl + 1 == pr) {
      c[p] = !!all[p];
    } else if (all[p] == 0) {
      c[p] = c[((p) << 1)] + c[(((p) << 1) | 1)];
    } else {
      c[p] = pr - pl;
    }
  }
  void update(int ql, int qr, int d) {
    this->ql = ql;
    this->qr = qr;
    this->d = d;
    _update(1, 0, N);
  }
  int query() { return c[1]; }
} st;
const int MAXN = 100000;
const int MAXM = 100000;
int n, m, tot;
int order[MAXN];
int l[MAXN], r[MAXN];
vector<int> add[MAXN], sub[MAXN + 1];
int res[MAXN];
vector<int> e[MAXN];
int a[MAXM], b[MAXM];
void dfs(int u, int fa) {
  order[tot] = u;
  l[u] = tot++;
  for (vector<int>::const_iterator i = e[u].begin(); i != e[u].end(); ++i) {
    if (*i != fa) {
      dfs(*i, u);
    }
  }
  r[u] = tot;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    e[u - 1].push_back(v - 1);
    e[v - 1].push_back(u - 1);
  }
  tot = 0;
  dfs(0, -1);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    --a[i];
    --b[i];
    add[l[a[i]]].push_back(i);
    add[l[b[i]]].push_back(i);
    sub[r[a[i]]].push_back(i);
    sub[r[b[i]]].push_back(i);
  }
  st.init(n);
  for (int i = 0; i < n; ++i) {
    for (vector<int>::const_iterator j = add[i].begin(); j != add[i].end();
         ++j) {
      st.update(l[a[*j]], r[a[*j]], 1);
      st.update(l[b[*j]], r[b[*j]], 1);
    }
    for (vector<int>::const_iterator j = sub[i].begin(); j != sub[i].end();
         ++j) {
      st.update(l[a[*j]], r[a[*j]], -1);
      st.update(l[b[*j]], r[b[*j]], -1);
    }
    res[order[i]] = st.query();
  }
  for (int i = 0; i < n; ++i) {
    printf("%d%c", res[i] == 0 ? 0 : res[i] - 1, i + 1 == n ? '\n' : ' ');
  }
  return 0;
}

```