#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long N = 100005;
struct segtree {
  long long val, cnt;
} tree[4 * N];
long long lazy[4 * N], in[N], out[N], tim = 0, n, m, ans[N];
vector<long long> g[N], q[N];
void build(long long node, long long l, long long r) {
  if (l == r) {
    tree[node].val = 0;
    tree[node].cnt = 1;
    return;
  }
  long long mid = (l + r) / 2;
  build(2 * node, l, mid);
  build(2 * node + 1, mid + 1, r);
  tree[node].val = min(tree[2 * node].val, tree[2 * node + 1].val);
  tree[node].cnt = 0;
  if (tree[node].val == tree[2 * node].val)
    tree[node].cnt += tree[2 * node].cnt;
  if (tree[node].val == tree[2 * node + 1].val)
    tree[node].cnt += tree[2 * node + 1].cnt;
}
void push(long long node, long long l, long long r) {
  if (lazy[node]) {
    tree[2 * node].val += lazy[node];
    lazy[2 * node] += lazy[node];
    tree[2 * node + 1].val += lazy[node];
    lazy[2 * node + 1] += lazy[node];
    lazy[node] = 0;
  }
}
void update(long long node, long long l, long long r, long long s, long long e,
            long long v) {
  if (s > r || e < l) return;
  if (s <= l && e >= r) {
    tree[node].val += v;
    lazy[node] += v;
    return;
  }
  long long mid = (l + r) / 2;
  push(node, l, r);
  update(2 * node, l, mid, s, e, v);
  update(2 * node + 1, mid + 1, r, s, e, v);
  tree[node].val = min(tree[2 * node].val, tree[2 * node + 1].val);
  tree[node].cnt = 0;
  if (tree[node].val == tree[2 * node].val)
    tree[node].cnt += tree[2 * node].cnt;
  if (tree[node].val == tree[2 * node + 1].val)
    tree[node].cnt += tree[2 * node + 1].cnt;
}
void dfs1(long long node, long long par) {
  ++tim;
  in[node] = tim;
  for (auto it : g[node]) {
    if (it == par) continue;
    dfs1(it, node);
  }
  out[node] = tim;
}
void dfs2(long long node, long long par) {
  for (auto it : q[node]) {
    update(1, 1, n, in[it], out[it], 1);
  }
  if ((long long)q[node].size()) update(1, 1, n, in[node], out[node], 1);
  if (tree[1].val)
    ans[node] = n;
  else
    ans[node] = (n - tree[1].cnt);
  for (auto it : g[node]) {
    if (it == par) continue;
    dfs2(it, node);
  }
  for (auto it : q[node]) {
    update(1, 1, n, in[it], out[it], -1);
  }
  if ((long long)q[node].size()) update(1, 1, n, in[node], out[node], -1);
}
void solve() {
  cin >> n >> m;
  for (long long i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (long long i = 1; i <= m; i++) {
    long long a, b;
    cin >> a >> b;
    q[a].push_back(b);
    q[b].push_back(a);
  }
  dfs1(1, 0);
  build(1, 1, n);
  dfs2(1, 0);
  for (long long i = 1; i <= n; i++) {
    if (ans[i] > 0) ans[i]--;
    cout << ans[i] << " ";
  }
  cout << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}

### Prompt

Please formulate a Cpp solution 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>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long long N = 100005;
struct segtree {
  long long val, cnt;
} tree[4 * N];
long long lazy[4 * N], in[N], out[N], tim = 0, n, m, ans[N];
vector<long long> g[N], q[N];
void build(long long node, long long l, long long r) {
  if (l == r) {
    tree[node].val = 0;
    tree[node].cnt = 1;
    return;
  }
  long long mid = (l + r) / 2;
  build(2 * node, l, mid);
  build(2 * node + 1, mid + 1, r);
  tree[node].val = min(tree[2 * node].val, tree[2 * node + 1].val);
  tree[node].cnt = 0;
  if (tree[node].val == tree[2 * node].val)
    tree[node].cnt += tree[2 * node].cnt;
  if (tree[node].val == tree[2 * node + 1].val)
    tree[node].cnt += tree[2 * node + 1].cnt;
}
void push(long long node, long long l, long long r) {
  if (lazy[node]) {
    tree[2 * node].val += lazy[node];
    lazy[2 * node] += lazy[node];
    tree[2 * node + 1].val += lazy[node];
    lazy[2 * node + 1] += lazy[node];
    lazy[node] = 0;
  }
}
void update(long long node, long long l, long long r, long long s, long long e,
            long long v) {
  if (s > r || e < l) return;
  if (s <= l && e >= r) {
    tree[node].val += v;
    lazy[node] += v;
    return;
  }
  long long mid = (l + r) / 2;
  push(node, l, r);
  update(2 * node, l, mid, s, e, v);
  update(2 * node + 1, mid + 1, r, s, e, v);
  tree[node].val = min(tree[2 * node].val, tree[2 * node + 1].val);
  tree[node].cnt = 0;
  if (tree[node].val == tree[2 * node].val)
    tree[node].cnt += tree[2 * node].cnt;
  if (tree[node].val == tree[2 * node + 1].val)
    tree[node].cnt += tree[2 * node + 1].cnt;
}
void dfs1(long long node, long long par) {
  ++tim;
  in[node] = tim;
  for (auto it : g[node]) {
    if (it == par) continue;
    dfs1(it, node);
  }
  out[node] = tim;
}
void dfs2(long long node, long long par) {
  for (auto it : q[node]) {
    update(1, 1, n, in[it], out[it], 1);
  }
  if ((long long)q[node].size()) update(1, 1, n, in[node], out[node], 1);
  if (tree[1].val)
    ans[node] = n;
  else
    ans[node] = (n - tree[1].cnt);
  for (auto it : g[node]) {
    if (it == par) continue;
    dfs2(it, node);
  }
  for (auto it : q[node]) {
    update(1, 1, n, in[it], out[it], -1);
  }
  if ((long long)q[node].size()) update(1, 1, n, in[node], out[node], -1);
}
void solve() {
  cin >> n >> m;
  for (long long i = 1; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (long long i = 1; i <= m; i++) {
    long long a, b;
    cin >> a >> b;
    q[a].push_back(b);
    q[b].push_back(a);
  }
  dfs1(1, 0);
  build(1, 1, n);
  dfs2(1, 0);
  for (long long i = 1; i <= n; i++) {
    if (ans[i] > 0) ans[i]--;
    cout << ans[i] << " ";
  }
  cout << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}

```