#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100007;
struct nd {
  int mn, cnt, lazy;
} tr[4 * MAXN];
nd combine(const nd& a, const nd& b) {
  nd rt;
  if (a.mn < b.mn)
    rt = a;
  else if (a.mn > b.mn)
    rt = b;
  else {
    rt.mn = a.mn;
    rt.cnt = a.cnt + b.cnt;
    rt.lazy = 0;
  }
  return rt;
}
void init(int u, int l, int r) {
  if (l == r) {
    tr[u].mn = tr[u].lazy = 0;
    tr[u].cnt = 1;
    return;
  }
  int mid = (l + r) / 2;
  init(u * 2, l, mid);
  init(u * 2 + 1, mid + 1, r);
  tr[u] = combine(tr[u * 2], tr[u * 2 + 1]);
}
void propagate(int u, int l, int r) {
  if (tr[u].lazy) {
    tr[u].mn += tr[u].lazy;
    if (l != r) {
      tr[u * 2].lazy += tr[u].lazy;
      tr[u * 2 + 1].lazy += tr[u].lazy;
    }
    tr[u].lazy = 0;
  }
}
void update(int u, int l, int r, int x, int y, int v) {
  propagate(u, l, r);
  if (y < l || r < x) return;
  if (x <= l && r <= y) {
    tr[u].lazy += v;
    propagate(u, l, r);
    return;
  }
  int mid = (l + r) / 2;
  update(u * 2, l, mid, x, y, v);
  update(u * 2 + 1, mid + 1, r, x, y, v);
  tr[u] = combine(tr[u * 2], tr[u * 2 + 1]);
}
vector<int> edg[MAXN];
int flat[MAXN], dhuka[MAXN], bahir[MAXN];
int tym;
void dfs(int u, int p) {
  tym++;
  flat[tym] = u;
  dhuka[u] = tym;
  for (int v : edg[u]) {
    if (v == p) continue;
    dfs(v, u);
  }
  bahir[u] = tym;
}
vector<pair<int, int> > inevents[MAXN];
vector<pair<int, int> > outevents[MAXN];
void handle(int a, int b) {
  int xa = dhuka[a], ya = bahir[a];
  int xb = dhuka[b], yb = bahir[b];
  inevents[xa].emplace_back(xa, ya);
  inevents[xa].emplace_back(xb, yb);
  inevents[xb].emplace_back(xa, ya);
  inevents[xb].emplace_back(xb, yb);
  outevents[ya].emplace_back(xa, ya);
  outevents[ya].emplace_back(xb, yb);
  outevents[yb].emplace_back(xa, ya);
  outevents[yb].emplace_back(xb, yb);
}
int ans[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    edg[u].push_back(v);
    edg[v].push_back(u);
  }
  dfs(1, 0);
  assert(tym == n);
  while (m--) {
    int a, b;
    cin >> a >> b;
    handle(a, b);
  }
  init(1, 1, n);
  int gz = 0;
  for (int i = 1; i <= n; i++) {
    for (pair<int, int> p : inevents[i]) {
      update(1, 1, n, p.first, p.second, 1);
      gz++;
    }
    update(1, 1, n, i, i, 1);
    int mn = tr[1].mn;
    int v = tr[1].cnt;
    assert(mn >= 0);
    if (mn == 0) {
      ans[flat[i]] = n - v - 1;
    } else {
      ans[flat[i]] = n - 1;
    }
    update(1, 1, n, i, i, -1);
    for (pair<int, int> p : outevents[i]) {
      update(1, 1, n, p.first, p.second, -1);
      gz--;
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  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 MAXN = 100007;
struct nd {
  int mn, cnt, lazy;
} tr[4 * MAXN];
nd combine(const nd& a, const nd& b) {
  nd rt;
  if (a.mn < b.mn)
    rt = a;
  else if (a.mn > b.mn)
    rt = b;
  else {
    rt.mn = a.mn;
    rt.cnt = a.cnt + b.cnt;
    rt.lazy = 0;
  }
  return rt;
}
void init(int u, int l, int r) {
  if (l == r) {
    tr[u].mn = tr[u].lazy = 0;
    tr[u].cnt = 1;
    return;
  }
  int mid = (l + r) / 2;
  init(u * 2, l, mid);
  init(u * 2 + 1, mid + 1, r);
  tr[u] = combine(tr[u * 2], tr[u * 2 + 1]);
}
void propagate(int u, int l, int r) {
  if (tr[u].lazy) {
    tr[u].mn += tr[u].lazy;
    if (l != r) {
      tr[u * 2].lazy += tr[u].lazy;
      tr[u * 2 + 1].lazy += tr[u].lazy;
    }
    tr[u].lazy = 0;
  }
}
void update(int u, int l, int r, int x, int y, int v) {
  propagate(u, l, r);
  if (y < l || r < x) return;
  if (x <= l && r <= y) {
    tr[u].lazy += v;
    propagate(u, l, r);
    return;
  }
  int mid = (l + r) / 2;
  update(u * 2, l, mid, x, y, v);
  update(u * 2 + 1, mid + 1, r, x, y, v);
  tr[u] = combine(tr[u * 2], tr[u * 2 + 1]);
}
vector<int> edg[MAXN];
int flat[MAXN], dhuka[MAXN], bahir[MAXN];
int tym;
void dfs(int u, int p) {
  tym++;
  flat[tym] = u;
  dhuka[u] = tym;
  for (int v : edg[u]) {
    if (v == p) continue;
    dfs(v, u);
  }
  bahir[u] = tym;
}
vector<pair<int, int> > inevents[MAXN];
vector<pair<int, int> > outevents[MAXN];
void handle(int a, int b) {
  int xa = dhuka[a], ya = bahir[a];
  int xb = dhuka[b], yb = bahir[b];
  inevents[xa].emplace_back(xa, ya);
  inevents[xa].emplace_back(xb, yb);
  inevents[xb].emplace_back(xa, ya);
  inevents[xb].emplace_back(xb, yb);
  outevents[ya].emplace_back(xa, ya);
  outevents[ya].emplace_back(xb, yb);
  outevents[yb].emplace_back(xa, ya);
  outevents[yb].emplace_back(xb, yb);
}
int ans[MAXN];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i < n; i++) {
    int u, v;
    cin >> u >> v;
    edg[u].push_back(v);
    edg[v].push_back(u);
  }
  dfs(1, 0);
  assert(tym == n);
  while (m--) {
    int a, b;
    cin >> a >> b;
    handle(a, b);
  }
  init(1, 1, n);
  int gz = 0;
  for (int i = 1; i <= n; i++) {
    for (pair<int, int> p : inevents[i]) {
      update(1, 1, n, p.first, p.second, 1);
      gz++;
    }
    update(1, 1, n, i, i, 1);
    int mn = tr[1].mn;
    int v = tr[1].cnt;
    assert(mn >= 0);
    if (mn == 0) {
      ans[flat[i]] = n - v - 1;
    } else {
      ans[flat[i]] = n - 1;
    }
    update(1, 1, n, i, i, -1);
    for (pair<int, int> p : outevents[i]) {
      update(1, 1, n, p.first, p.second, -1);
      gz--;
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
  return 0;
}

```