#include <bits/stdc++.h>
using std::make_pair;
using std::pair;
using std::vector;
const int N = 100000;
int n, m, label_count, label[N], size[N], position[N];
vector<int> tree[N];
void dfs(int p, int u) {
  label[u] = label_count++;
  position[label[u]] = u;
  size[u] = 1;
  for (__typeof((tree[u]).begin()) iter = (tree[u]).begin();
       iter != (tree[u]).end(); ++iter) {
    if (*iter != p) {
      dfs(u, *iter);
      size[u] += size[*iter];
    }
  }
}
int a[N], b[N];
vector<pair<int, int> > events;
int get_id(int l, int r) { return l + r | l != r; }
int cover[N << 1], total[N << 1];
void update(int l, int r) {
  int m = l + r >> 1;
  total[get_id(l, r)] = total[get_id(l, m)] + total[get_id(m + 1, r)];
  if (cover[get_id(l, r)]) {
    total[get_id(l, r)] = r - l + 1;
  }
}
void modify(int l, int r, int a, int b, int c) {
  if (b < l || r < a) {
    return;
  }
  if (a <= l && r <= b) {
    cover[get_id(l, r)] += c;
    if (l == r) {
      total[get_id(l, r)] = cover[get_id(l, r)] > 0;
    } else {
      update(l, r);
    }
    return;
  }
  int m = l + r >> 1;
  modify(l, m, a, b, c);
  modify(m + 1, r, a, b, c);
  update(l, r);
}
int answer[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  label_count = 0;
  dfs(-1, 0);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", a + i, b + i);
    a[i]--;
    b[i]--;
    events.push_back(make_pair(label[a[i]], i << 1));
    events.push_back(make_pair(label[a[i]] + size[a[i]], (i << 1) | 1));
    events.push_back(make_pair(label[b[i]], i << 1));
    events.push_back(make_pair(label[b[i]] + size[b[i]], (i << 1) | 1));
  }
  std::sort(events.begin(), events.end());
  memset(cover, 0, sizeof(cover));
  for (int now = 0, pt = 0; now < n; ++now) {
    while (pt < (int)events.size() && events[pt].first == now) {
      int id = events[pt].second >> 1;
      int delta = (events[pt].second & 1) ? -1 : 1;
      modify(0, n - 1, label[a[id]], label[a[id]] + size[a[id]] - 1, delta);
      modify(0, n - 1, label[b[id]], label[b[id]] + size[b[id]] - 1, delta);
      pt++;
    }
    answer[position[now]] = std::max(total[get_id(0, n - 1)] - 1, 0);
  }
  for (int i = 0; i < n; ++i) {
    printf("%d%c", answer[i], i == n - 1 ? '\n' : ' ');
  }
  return 0;
}

### Prompt

Your task is to create 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>
using std::make_pair;
using std::pair;
using std::vector;
const int N = 100000;
int n, m, label_count, label[N], size[N], position[N];
vector<int> tree[N];
void dfs(int p, int u) {
  label[u] = label_count++;
  position[label[u]] = u;
  size[u] = 1;
  for (__typeof((tree[u]).begin()) iter = (tree[u]).begin();
       iter != (tree[u]).end(); ++iter) {
    if (*iter != p) {
      dfs(u, *iter);
      size[u] += size[*iter];
    }
  }
}
int a[N], b[N];
vector<pair<int, int> > events;
int get_id(int l, int r) { return l + r | l != r; }
int cover[N << 1], total[N << 1];
void update(int l, int r) {
  int m = l + r >> 1;
  total[get_id(l, r)] = total[get_id(l, m)] + total[get_id(m + 1, r)];
  if (cover[get_id(l, r)]) {
    total[get_id(l, r)] = r - l + 1;
  }
}
void modify(int l, int r, int a, int b, int c) {
  if (b < l || r < a) {
    return;
  }
  if (a <= l && r <= b) {
    cover[get_id(l, r)] += c;
    if (l == r) {
      total[get_id(l, r)] = cover[get_id(l, r)] > 0;
    } else {
      update(l, r);
    }
    return;
  }
  int m = l + r >> 1;
  modify(l, m, a, b, c);
  modify(m + 1, r, a, b, c);
  update(l, r);
}
int answer[N];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    tree[a].push_back(b);
    tree[b].push_back(a);
  }
  label_count = 0;
  dfs(-1, 0);
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", a + i, b + i);
    a[i]--;
    b[i]--;
    events.push_back(make_pair(label[a[i]], i << 1));
    events.push_back(make_pair(label[a[i]] + size[a[i]], (i << 1) | 1));
    events.push_back(make_pair(label[b[i]], i << 1));
    events.push_back(make_pair(label[b[i]] + size[b[i]], (i << 1) | 1));
  }
  std::sort(events.begin(), events.end());
  memset(cover, 0, sizeof(cover));
  for (int now = 0, pt = 0; now < n; ++now) {
    while (pt < (int)events.size() && events[pt].first == now) {
      int id = events[pt].second >> 1;
      int delta = (events[pt].second & 1) ? -1 : 1;
      modify(0, n - 1, label[a[id]], label[a[id]] + size[a[id]] - 1, delta);
      modify(0, n - 1, label[b[id]], label[b[id]] + size[b[id]] - 1, delta);
      pt++;
    }
    answer[position[now]] = std::max(total[get_id(0, n - 1)] - 1, 0);
  }
  for (int i = 0; i < n; ++i) {
    printf("%d%c", answer[i], i == n - 1 ? '\n' : ' ');
  }
  return 0;
}

```