#include <bits/stdc++.h>
using namespace std;
struct bit {
  bit() { memset((arr), (0), sizeof(arr)); }
  int arr[200100];
  void inc(int a, int t) {
    a += 2;
    while (a < 200100) {
      arr[a] += t;
      a += a & -a;
    }
  }
  int get(int a) {
    int s = 0;
    a += 2;
    while (a) {
      s += arr[a];
      a -= a & -a;
    }
    return s;
  }
};
vector<int> adj[100100];
int ent[100100], exi[100100];
int treez[100100];
int z = 0;
void dfs(int a, int p) {
  ent[a] = z++;
  treez[a] = 1;
  for (__typeof((adj[a]).begin()) i = (adj[a]).begin(), _i = (adj[a]).end();
       i != _i; ++i) {
    int b = *i;
    if (b != p) {
      dfs(b, a);
      treez[a] += treez[b];
    }
  }
  exi[a] = z++;
}
bit incdec;
bit inc;
int sum = 0;
stack<int> t, amt;
int z2 = 0;
void add(int a) {
  int q = incdec.get(ent[a]);
  if (q == 0) {
    incdec.inc(ent[a], 1);
    incdec.inc(exi[a], -1);
    int prev = inc.get(exi[a]) - inc.get(ent[a] - 1);
    int dif = treez[a] - prev;
    inc.inc(ent[a], dif);
    sum += dif;
    t.push(z2);
    amt.push(dif);
  }
}
void undo(int a) {
  if (t.top() == z2) {
    int dif = amt.top();
    incdec.inc(ent[a], -1);
    incdec.inc(exi[a], 1);
    inc.inc(ent[a], -dif);
    sum -= dif;
    t.pop();
    amt.pop();
  }
}
vector<int> oth[100100];
int ans[100100];
void calc(int a, int p) {
  for (__typeof((oth[a]).begin()) i = (oth[a]).begin(), _i = (oth[a]).end();
       i != _i; ++i) {
    z2++;
    add(a);
    z2++;
    add(*i);
  }
  ans[a] = sum;
  for (__typeof((adj[a]).begin()) i = (adj[a]).begin(), _i = (adj[a]).end();
       i != _i; ++i) {
    int b = *i;
    if (b != p) {
      calc(b, a);
    }
  }
  for (__typeof((oth[a]).rbegin()) i = (oth[a]).rbegin(), _i = (oth[a]).rend();
       i != _i; ++i) {
    undo(*i);
    z2--;
    undo(a);
    z2--;
  }
}
int main() {
  cout << fixed << setprecision(12);
  t.push(-1);
  amt.push(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0, _i = (n - 1); i < _i; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(0, -1);
  for (int i = 0, _i = (m); i < _i; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    oth[a].push_back(b);
    oth[b].push_back(a);
  }
  calc(0, -1);
  for (int i = 0, _i = (n); i < _i; ++i) {
    if (i) cout << ' ';
    cout << max(0, ans[i] - 1);
  }
  cout << endl;
}

### 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;
struct bit {
  bit() { memset((arr), (0), sizeof(arr)); }
  int arr[200100];
  void inc(int a, int t) {
    a += 2;
    while (a < 200100) {
      arr[a] += t;
      a += a & -a;
    }
  }
  int get(int a) {
    int s = 0;
    a += 2;
    while (a) {
      s += arr[a];
      a -= a & -a;
    }
    return s;
  }
};
vector<int> adj[100100];
int ent[100100], exi[100100];
int treez[100100];
int z = 0;
void dfs(int a, int p) {
  ent[a] = z++;
  treez[a] = 1;
  for (__typeof((adj[a]).begin()) i = (adj[a]).begin(), _i = (adj[a]).end();
       i != _i; ++i) {
    int b = *i;
    if (b != p) {
      dfs(b, a);
      treez[a] += treez[b];
    }
  }
  exi[a] = z++;
}
bit incdec;
bit inc;
int sum = 0;
stack<int> t, amt;
int z2 = 0;
void add(int a) {
  int q = incdec.get(ent[a]);
  if (q == 0) {
    incdec.inc(ent[a], 1);
    incdec.inc(exi[a], -1);
    int prev = inc.get(exi[a]) - inc.get(ent[a] - 1);
    int dif = treez[a] - prev;
    inc.inc(ent[a], dif);
    sum += dif;
    t.push(z2);
    amt.push(dif);
  }
}
void undo(int a) {
  if (t.top() == z2) {
    int dif = amt.top();
    incdec.inc(ent[a], -1);
    incdec.inc(exi[a], 1);
    inc.inc(ent[a], -dif);
    sum -= dif;
    t.pop();
    amt.pop();
  }
}
vector<int> oth[100100];
int ans[100100];
void calc(int a, int p) {
  for (__typeof((oth[a]).begin()) i = (oth[a]).begin(), _i = (oth[a]).end();
       i != _i; ++i) {
    z2++;
    add(a);
    z2++;
    add(*i);
  }
  ans[a] = sum;
  for (__typeof((adj[a]).begin()) i = (adj[a]).begin(), _i = (adj[a]).end();
       i != _i; ++i) {
    int b = *i;
    if (b != p) {
      calc(b, a);
    }
  }
  for (__typeof((oth[a]).rbegin()) i = (oth[a]).rbegin(), _i = (oth[a]).rend();
       i != _i; ++i) {
    undo(*i);
    z2--;
    undo(a);
    z2--;
  }
}
int main() {
  cout << fixed << setprecision(12);
  t.push(-1);
  amt.push(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0, _i = (n - 1); i < _i; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(0, -1);
  for (int i = 0, _i = (m); i < _i; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    oth[a].push_back(b);
    oth[b].push_back(a);
  }
  calc(0, -1);
  for (int i = 0, _i = (n); i < _i; ++i) {
    if (i) cout << ' ';
    cout << max(0, ans[i] - 1);
  }
  cout << endl;
}

```