#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
long long qp(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
template <class T>
inline bool scan(T& ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
int val[maxn << 2], lazy[maxn << 2];
int n, m;
vector<int> edge[maxn];
vector<int> q[maxn];
int idx[maxn], ed[maxn];
int res[maxn];
int le, re, k;
int tot;
int sta[1 << 18], stb[1 << 19];
void upd(int l1, int r1, int x, int i = 1, int l2 = 0, int r2 = n - 1) {
  if (!(l1 <= l2 && r2 <= r1)) {
    int m2 = (l2 + r2) / 2;
    if (l1 <= m2) upd(l1, r1, x, 2 * i, l2, m2);
    if (m2 < r1) upd(l1, r1, x, 2 * i + 1, m2 + 1, r2);
  } else
    sta[i] += x;
  stb[i] = sta[i] ? r2 - l2 + 1 : stb[2 * i] + stb[2 * i + 1];
}
void update(int rt, int l, int r) {
  if (le <= l && r <= re) {
    val[rt] += k * (r - l + 1);
    lazy[rt] += k;
    return;
  }
  int mid = l + r >> 1;
  int len = r - l + 1;
  if (lazy[rt]) {
    val[rt << 1] += lazy[rt] * (len - len / 2);
    val[rt << 1 | 1] += lazy[rt] * (len / 2);
    lazy[rt << 1] += lazy[rt];
    lazy[rt << 1 | 1] += lazy[rt];
    lazy[rt] = 0;
  }
  if (le <= mid) update(rt << 1, l, mid);
  if (re > mid) update(rt << 1 | 1, mid + 1, r);
  val[rt] = val[rt << 1] + val[rt << 1 | 1];
}
void dfs1(int u, int pre) {
  idx[u] = ++tot - 1;
  for (auto v : edge[u]) {
    if (v == pre) continue;
    dfs1(v, u);
  }
  ed[u] = tot - 1;
}
void dfs2(int u, int pre) {
  if (!q[u].empty()) {
    upd(idx[u], ed[u], 1);
  }
  for (auto i : q[u]) {
    upd(idx[i], ed[i], 1);
  }
  res[u] = max(0, stb[1] - 1);
  for (auto v : edge[u]) {
    if (v == pre) continue;
    dfs2(v, u);
  }
  if (!q[u].empty()) {
    upd(idx[u], ed[u], -1);
  }
  for (auto i : q[u]) {
    upd(idx[i], ed[i], -1);
  }
}
int main(int argc, char* argv[]) {
  scan(n), scan(m);
  for (int i = 1, u, v; i < n; ++i) {
    scan(u), scan(v);
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  for (int i = 1, u, v; i <= m; ++i) {
    scan(u), scan(v);
    q[u].push_back(v);
    q[v].push_back(u);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  for (int i = 1; i <= n; ++i) printf("%d ", res[i]);
  return 0;
}

### Prompt

Create a solution in Cpp for 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 = 1e5 + 5;
const int mod = 1e9 + 7;
long long qp(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
template <class T>
inline bool scan(T& ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1;
  ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
int val[maxn << 2], lazy[maxn << 2];
int n, m;
vector<int> edge[maxn];
vector<int> q[maxn];
int idx[maxn], ed[maxn];
int res[maxn];
int le, re, k;
int tot;
int sta[1 << 18], stb[1 << 19];
void upd(int l1, int r1, int x, int i = 1, int l2 = 0, int r2 = n - 1) {
  if (!(l1 <= l2 && r2 <= r1)) {
    int m2 = (l2 + r2) / 2;
    if (l1 <= m2) upd(l1, r1, x, 2 * i, l2, m2);
    if (m2 < r1) upd(l1, r1, x, 2 * i + 1, m2 + 1, r2);
  } else
    sta[i] += x;
  stb[i] = sta[i] ? r2 - l2 + 1 : stb[2 * i] + stb[2 * i + 1];
}
void update(int rt, int l, int r) {
  if (le <= l && r <= re) {
    val[rt] += k * (r - l + 1);
    lazy[rt] += k;
    return;
  }
  int mid = l + r >> 1;
  int len = r - l + 1;
  if (lazy[rt]) {
    val[rt << 1] += lazy[rt] * (len - len / 2);
    val[rt << 1 | 1] += lazy[rt] * (len / 2);
    lazy[rt << 1] += lazy[rt];
    lazy[rt << 1 | 1] += lazy[rt];
    lazy[rt] = 0;
  }
  if (le <= mid) update(rt << 1, l, mid);
  if (re > mid) update(rt << 1 | 1, mid + 1, r);
  val[rt] = val[rt << 1] + val[rt << 1 | 1];
}
void dfs1(int u, int pre) {
  idx[u] = ++tot - 1;
  for (auto v : edge[u]) {
    if (v == pre) continue;
    dfs1(v, u);
  }
  ed[u] = tot - 1;
}
void dfs2(int u, int pre) {
  if (!q[u].empty()) {
    upd(idx[u], ed[u], 1);
  }
  for (auto i : q[u]) {
    upd(idx[i], ed[i], 1);
  }
  res[u] = max(0, stb[1] - 1);
  for (auto v : edge[u]) {
    if (v == pre) continue;
    dfs2(v, u);
  }
  if (!q[u].empty()) {
    upd(idx[u], ed[u], -1);
  }
  for (auto i : q[u]) {
    upd(idx[i], ed[i], -1);
  }
}
int main(int argc, char* argv[]) {
  scan(n), scan(m);
  for (int i = 1, u, v; i < n; ++i) {
    scan(u), scan(v);
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  for (int i = 1, u, v; i <= m; ++i) {
    scan(u), scan(v);
    q[u].push_back(v);
    q[v].push_back(u);
  }
  dfs1(1, 0);
  dfs2(1, 0);
  for (int i = 1; i <= n; ++i) printf("%d ", res[i]);
  return 0;
}

```