#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 100 + 10;
int n, m, st[N], en[N], TM, ans[N];
vector<int> adj[N], query[N];
struct Node {
  int mn = 0, s = 0, lazy = 0;
  Node(int x = 0, int y = 0, int z = 0) { mn = x, s = y, lazy = z; }
  void merge(Node L, Node R) {
    mn = min(L.mn, R.mn);
    s = 0;
    if (L.mn == mn) s += L.s;
    if (R.mn == mn) s += R.s;
  }
  void add(int x) {
    lazy += x;
    mn += x;
  }
} seg[N << 2];
void shift(int id) {
  seg[id << 1].add(seg[id].lazy), seg[id << 1 | 1].add(seg[id].lazy);
  seg[id].lazy = 0;
}
void build(int l = 0, int r = n, int id = 1) {
  seg[id].s = r - l;
  if (l + 1 == r) return;
  int mid = l + r >> 1;
  build(l, mid, id << 1), build(mid, r, id << 1 | 1);
}
Node get(int s, int e, int l = 0, int r = n, int id = 1) {
  if (s <= l && e >= r) return seg[id];
  if (s >= r || e <= l) return Node(1 << 30, 0, 0);
  shift(id);
  int mid = l + r >> 1;
  Node res;
  res.merge(get(s, e, l, mid, id << 1), get(s, e, mid, r, id << 1 | 1));
  return res;
}
void upd(int s, int e, int w, int l = 0, int r = n, int id = 1) {
  if (s <= l && e >= r) {
    seg[id].add(w);
    return;
  }
  if (s >= r || e <= l) return;
  shift(id);
  int mid = l + r >> 1;
  upd(s, e, w, l, mid, id << 1), upd(s, e, w, mid, r, id << 1 | 1);
  seg[id].merge(seg[id << 1], seg[id << 1 | 1]);
}
void dfs(int v, int par = 0) {
  st[v] = TM++;
  for (auto u : adj[v])
    if (u != par) dfs(u, v);
  en[v] = TM;
}
void dfs_ans(int v, int par = 0) {
  ans[v] += ans[par];
  upd(st[v], st[v] + 1, 1);
  for (auto x : query[v]) {
    Node res = get(st[x], en[x]);
    ans[v] += (res.mn == 0 ? res.s : 0);
    upd(st[x], en[x], 1);
  }
  for (auto u : adj[v])
    if (u != par) dfs_ans(u, v);
  for (auto x : query[v]) upd(st[x], en[x], -1);
  upd(st[v], st[v] + 1, -1);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 1, v, u; i < n; i++) {
    cin >> v >> u;
    adj[v].push_back(u);
    adj[u].push_back(v);
  }
  for (int i = 1, a, b; i <= m; i++) {
    cin >> a >> b;
    query[a].push_back(b);
    query[b].push_back(a);
    query[a].push_back(a), query[b].push_back(b);
  }
  dfs(1);
  build();
  dfs_ans(1);
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
  cout << '\n';
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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 N = 1000 * 100 + 10;
int n, m, st[N], en[N], TM, ans[N];
vector<int> adj[N], query[N];
struct Node {
  int mn = 0, s = 0, lazy = 0;
  Node(int x = 0, int y = 0, int z = 0) { mn = x, s = y, lazy = z; }
  void merge(Node L, Node R) {
    mn = min(L.mn, R.mn);
    s = 0;
    if (L.mn == mn) s += L.s;
    if (R.mn == mn) s += R.s;
  }
  void add(int x) {
    lazy += x;
    mn += x;
  }
} seg[N << 2];
void shift(int id) {
  seg[id << 1].add(seg[id].lazy), seg[id << 1 | 1].add(seg[id].lazy);
  seg[id].lazy = 0;
}
void build(int l = 0, int r = n, int id = 1) {
  seg[id].s = r - l;
  if (l + 1 == r) return;
  int mid = l + r >> 1;
  build(l, mid, id << 1), build(mid, r, id << 1 | 1);
}
Node get(int s, int e, int l = 0, int r = n, int id = 1) {
  if (s <= l && e >= r) return seg[id];
  if (s >= r || e <= l) return Node(1 << 30, 0, 0);
  shift(id);
  int mid = l + r >> 1;
  Node res;
  res.merge(get(s, e, l, mid, id << 1), get(s, e, mid, r, id << 1 | 1));
  return res;
}
void upd(int s, int e, int w, int l = 0, int r = n, int id = 1) {
  if (s <= l && e >= r) {
    seg[id].add(w);
    return;
  }
  if (s >= r || e <= l) return;
  shift(id);
  int mid = l + r >> 1;
  upd(s, e, w, l, mid, id << 1), upd(s, e, w, mid, r, id << 1 | 1);
  seg[id].merge(seg[id << 1], seg[id << 1 | 1]);
}
void dfs(int v, int par = 0) {
  st[v] = TM++;
  for (auto u : adj[v])
    if (u != par) dfs(u, v);
  en[v] = TM;
}
void dfs_ans(int v, int par = 0) {
  ans[v] += ans[par];
  upd(st[v], st[v] + 1, 1);
  for (auto x : query[v]) {
    Node res = get(st[x], en[x]);
    ans[v] += (res.mn == 0 ? res.s : 0);
    upd(st[x], en[x], 1);
  }
  for (auto u : adj[v])
    if (u != par) dfs_ans(u, v);
  for (auto x : query[v]) upd(st[x], en[x], -1);
  upd(st[v], st[v] + 1, -1);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  for (int i = 1, v, u; i < n; i++) {
    cin >> v >> u;
    adj[v].push_back(u);
    adj[u].push_back(v);
  }
  for (int i = 1, a, b; i <= m; i++) {
    cin >> a >> b;
    query[a].push_back(b);
    query[b].push_back(a);
    query[a].push_back(a), query[b].push_back(b);
  }
  dfs(1);
  build();
  dfs_ans(1);
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
  cout << '\n';
  return 0;
}

```