#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
vector<int> adj[MAXN], lig[MAXN];
int n, m, x, y, ind[MAXN], inv[MAXN], fim[MAXN], degi = 1, res[MAXN], mrk[MAXN];
struct node {
  int mn, nm, lz;
} tree[4 * MAXN], resu;
void build(int idx, int i, int f) {
  if (i == f) {
    tree[idx].lz = tree[idx].mn = 0;
    tree[idx].nm = 1;
    return;
  }
  int m = (i + f) / 2;
  build(idx * 2, i, m);
  build(idx * 2 + 1, m + 1, f);
  tree[idx].nm = tree[idx * 2].nm + tree[idx * 2 + 1].nm;
}
void upd(int idx, int i, int f, int l, int r, int com) {
  if (f < l || i > r) return;
  if (tree[idx].lz != 0) {
    int aux = tree[idx].lz;
    tree[idx].lz = 0;
    if (i != f) {
      tree[idx * 2].lz += aux;
      tree[idx * 2].mn += aux;
      tree[idx * 2 + 1].lz += aux;
      tree[idx * 2 + 1].mn += aux;
    }
  }
  if (i >= l && f <= r) {
    tree[idx].mn += com;
    tree[idx].lz += com;
    return;
  }
  int m = (i + f) / 2;
  upd(idx * 2, i, m, l, r, com);
  upd(idx * 2 + 1, m + 1, f, l, r, com);
  if (tree[idx * 2].mn == tree[idx * 2 + 1].mn) {
    tree[idx].mn = tree[idx * 2].mn;
    tree[idx].nm = tree[idx * 2].nm + tree[idx * 2 + 1].nm;
  } else if (tree[idx * 2].mn < tree[idx * 2 + 1].mn) {
    tree[idx].mn = tree[idx * 2].mn;
    tree[idx].nm = tree[idx * 2].nm;
  } else {
    tree[idx].mn = tree[idx * 2 + 1].mn;
    tree[idx].nm = tree[idx * 2 + 1].nm;
  }
}
void go(int v) {
  mrk[v] = 1;
  int xx = ind[v];
  for (int a = 0; a < lig[xx].size(); a++) {
    int yy = lig[xx][a];
    upd(1, 1, n, xx, fim[xx], 1);
    upd(1, 1, n, yy, fim[yy], 1);
  }
  resu = tree[1];
  if (resu.mn == 0)
    res[v] = n - resu.nm;
  else
    res[v] = n;
  for (int a = 0; a < adj[v].size(); a++) {
    int prox = adj[v][a];
    if (mrk[prox] == 1) continue;
    go(prox);
  }
  for (int a = 0; a < lig[xx].size(); a++) {
    int yy = lig[xx][a];
    upd(1, 1, n, xx, fim[xx], -1);
    upd(1, 1, n, yy, fim[yy], -1);
  }
}
void dfs(int v) {
  mrk[v] = 1;
  ind[v] = degi++;
  int xx = ind[v];
  fim[xx] = xx;
  for (int a = 0; a < adj[v].size(); a++) {
    int prox = adj[v][a];
    if (mrk[prox] == 1) continue;
    dfs(prox);
    int yy = ind[prox];
    fim[xx] = fim[yy];
  }
}
int main() {
  scanf("%d%d", &n, &m);
  build(1, 1, n);
  for (int a = 0; a < n - 1; a++) {
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1);
  memset(mrk, 0, sizeof(mrk));
  for (int a = 0; a < m; a++) {
    scanf("%d%d", &x, &y);
    int xx = ind[x], yy = ind[y];
    lig[xx].push_back(yy);
    lig[yy].push_back(xx);
  }
  go(1);
  for (int a = 1; a <= n; a++) {
    if (res[a] != 0) res[a]--;
    printf("%d ", res[a]);
  }
  scanf("%*d");
  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 namespace std;
const int MAXN = 100010;
vector<int> adj[MAXN], lig[MAXN];
int n, m, x, y, ind[MAXN], inv[MAXN], fim[MAXN], degi = 1, res[MAXN], mrk[MAXN];
struct node {
  int mn, nm, lz;
} tree[4 * MAXN], resu;
void build(int idx, int i, int f) {
  if (i == f) {
    tree[idx].lz = tree[idx].mn = 0;
    tree[idx].nm = 1;
    return;
  }
  int m = (i + f) / 2;
  build(idx * 2, i, m);
  build(idx * 2 + 1, m + 1, f);
  tree[idx].nm = tree[idx * 2].nm + tree[idx * 2 + 1].nm;
}
void upd(int idx, int i, int f, int l, int r, int com) {
  if (f < l || i > r) return;
  if (tree[idx].lz != 0) {
    int aux = tree[idx].lz;
    tree[idx].lz = 0;
    if (i != f) {
      tree[idx * 2].lz += aux;
      tree[idx * 2].mn += aux;
      tree[idx * 2 + 1].lz += aux;
      tree[idx * 2 + 1].mn += aux;
    }
  }
  if (i >= l && f <= r) {
    tree[idx].mn += com;
    tree[idx].lz += com;
    return;
  }
  int m = (i + f) / 2;
  upd(idx * 2, i, m, l, r, com);
  upd(idx * 2 + 1, m + 1, f, l, r, com);
  if (tree[idx * 2].mn == tree[idx * 2 + 1].mn) {
    tree[idx].mn = tree[idx * 2].mn;
    tree[idx].nm = tree[idx * 2].nm + tree[idx * 2 + 1].nm;
  } else if (tree[idx * 2].mn < tree[idx * 2 + 1].mn) {
    tree[idx].mn = tree[idx * 2].mn;
    tree[idx].nm = tree[idx * 2].nm;
  } else {
    tree[idx].mn = tree[idx * 2 + 1].mn;
    tree[idx].nm = tree[idx * 2 + 1].nm;
  }
}
void go(int v) {
  mrk[v] = 1;
  int xx = ind[v];
  for (int a = 0; a < lig[xx].size(); a++) {
    int yy = lig[xx][a];
    upd(1, 1, n, xx, fim[xx], 1);
    upd(1, 1, n, yy, fim[yy], 1);
  }
  resu = tree[1];
  if (resu.mn == 0)
    res[v] = n - resu.nm;
  else
    res[v] = n;
  for (int a = 0; a < adj[v].size(); a++) {
    int prox = adj[v][a];
    if (mrk[prox] == 1) continue;
    go(prox);
  }
  for (int a = 0; a < lig[xx].size(); a++) {
    int yy = lig[xx][a];
    upd(1, 1, n, xx, fim[xx], -1);
    upd(1, 1, n, yy, fim[yy], -1);
  }
}
void dfs(int v) {
  mrk[v] = 1;
  ind[v] = degi++;
  int xx = ind[v];
  fim[xx] = xx;
  for (int a = 0; a < adj[v].size(); a++) {
    int prox = adj[v][a];
    if (mrk[prox] == 1) continue;
    dfs(prox);
    int yy = ind[prox];
    fim[xx] = fim[yy];
  }
}
int main() {
  scanf("%d%d", &n, &m);
  build(1, 1, n);
  for (int a = 0; a < n - 1; a++) {
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1);
  memset(mrk, 0, sizeof(mrk));
  for (int a = 0; a < m; a++) {
    scanf("%d%d", &x, &y);
    int xx = ind[x], yy = ind[y];
    lig[xx].push_back(yy);
    lig[yy].push_back(xx);
  }
  go(1);
  for (int a = 1; a <= n; a++) {
    if (res[a] != 0) res[a]--;
    printf("%d ", res[a]);
  }
  scanf("%*d");
  return 0;
}

```