#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5, inf = 1e9 + 5, L = 24;
int n, q, stt[maxn], ftt[maxn], ti, par[maxn][L], h[maxn];
int lzy[maxn << 2], mx;
vector<int> adj[maxn];
set<pair<int, int> > st;
pair<int, int> seg[maxn << 2];
pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first) return {a.first, a.second + b.second};
  if (a.first < b.first) return b;
  return a;
}
void build(int l = 0, int r = n, int id = 1) {
  seg[id] = {0, r - l};
  if (r - l == 1) {
    return;
  }
  int mid = l + r >> 1;
  build(l, mid, id << 1);
  build(mid, r, id << 1 | 1);
}
void shift(int id) {
  lzy[id << 1] += lzy[id];
  lzy[id << 1 | 1] += lzy[id];
  seg[id << 1].first += lzy[id];
  seg[id << 1 | 1].first += lzy[id];
  lzy[id] = 0;
}
void add(int ql, int qr, int val, int l = 0, int r = n, int id = 1) {
  if (max(ql, l) >= min(qr, r)) return;
  if (ql <= l && qr >= r) {
    seg[id].first += val;
    lzy[id] += val;
    return;
  }
  shift(id);
  int mid = l + r >> 1;
  add(ql, qr, val, l, mid, id << 1);
  add(ql, qr, val, mid, r, id << 1 | 1);
  seg[id] = seg[id << 1] + seg[id << 1 | 1];
}
void dfs(int v = 0, int p = -1) {
  par[v][0] = p;
  for (int i = 1; i < L; i++)
    par[v][i] = (par[v][i - 1] == -1 ? -1 : par[par[v][i - 1]][i - 1]);
  stt[v] = ti++;
  for (auto u : adj[v])
    if (u != p) h[u] = h[v] + 1, dfs(u, v);
  ftt[v] = ti;
}
int getpar(int v, int p) {
  for (int i = L - 1; i >= 0; i--) {
    if (p >= (1 << i)) {
      v = par[v][i];
      p -= (1 << i);
    }
    if (v == -1) break;
  }
  return v;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs();
  build();
  while (q--) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    bool b = 0;
    if (stt[x] < stt[y] && ftt[x] >= ftt[y]) {
      if (st.count({min(x, y), max(x, y)})) {
        mx--;
        add(stt[y], ftt[y], -1);
        add(0, n, -1);
        int d = h[y] - h[x];
        add(stt[getpar(y, d - 1)], ftt[getpar(y, d - 1)], 1);
        st.erase({min(x, y), max(x, y)});
      } else {
        mx++;
        add(stt[y], ftt[y], 1);
        add(0, n, 1);
        int d = h[y] - h[x];
        add(stt[getpar(y, d - 1)], ftt[getpar(y, d - 1)], -1);
        st.insert({min(x, y), max(x, y)});
      }
      b = 1;
    }
    swap(x, y);
    if (!b && stt[x] < stt[y] && ftt[x] >= ftt[y]) {
      if (st.count({min(x, y), max(x, y)})) {
        mx--;
        add(stt[y], ftt[y], -1);
        add(0, n, -1);
        int d = h[y] - h[x];
        add(stt[getpar(y, d - 1)], ftt[getpar(y, d - 1)], 1);
        st.erase({min(x, y), max(x, y)});
      } else {
        mx++;
        add(stt[y], ftt[y], 1);
        add(0, n, 1);
        int d = h[y] - h[x];
        add(stt[getpar(y, d - 1)], ftt[getpar(y, d - 1)], -1);
        st.insert({min(x, y), max(x, y)});
      }
      b = 1;
    }
    if (!b) {
      if (st.count({min(x, y), max(x, y)})) {
        mx--;
        add(stt[y], ftt[y], -1);
        add(stt[x], ftt[x], -1);
        st.erase({min(x, y), max(x, y)});
      } else {
        mx++;
        add(stt[y], ftt[y], 1);
        add(stt[x], ftt[x], 1);
        st.insert({min(x, y), max(x, y)});
      }
    }
    if (seg[1].first == mx)
      cout << seg[1].second << '\n';
    else
      cout << 0 << '\n';
  }
}

### Prompt

In Cpp, your task is to solve the following problem:

Let T be a tree on n vertices. Consider a graph G_0, initially equal to T. You are given a sequence of q updates, where the i-th update is given as a pair of two distinct integers u_i and v_i. 

For every i from 1 to q, we define the graph G_i as follows: 

  * If G_{i-1} contains an edge \\{u_i, v_i\}, then remove this edge to form G_i. 
  * Otherwise, add this edge to G_{i-1} to form G_i. 



Formally, G_i := G_{i-1} \triangle \{\\{u_i, v_i\}\} where \triangle denotes the set [symmetric difference](https://en.wikipedia.org/wiki/Symmetric_difference). 

Furthermore, it is guaranteed that T is always a subgraph of G_i. In other words, an update never removes an edge of T.

Consider a connected graph H and run a depth-first search on it. One can see that the tree edges (i.e. the edges leading to a not yet visited vertex at the time of traversal) form a spanning tree of the graph H. This spanning tree is not generally fixed for a particular graph — it depends on the starting vertex, and on the order in which the neighbors of each vertex are traversed. 

We call vertex w good if one can order the neighbors of each vertex in such a way that the depth-first search started from w produces T as the spanning tree. For every i from 1 to q, find and report the number of good vertices.

Input

The first line contains two integers n and q (3 ≤ n ≤ 2⋅ 10^5, 1 ≤ q ≤ 2 ⋅ 10^5) — the number of nodes and the number of updates, respectively.

Each of the next n-1 lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — vertices connected by an edge in T. It is guaranteed that this graph is a tree.

Each of the next q lines contains two integers u and v (1 ≤ u, v ≤ n, u ≠ v) — the endpoints of the edge that is added or removed. It is guaranteed that this edge does not belong to T.

Output

For each update, print one integer k — the number of good vertices w after the corresponding update.

Examples

Input

3 2
1 2
1 3
2 3
3 2


Output

2
3


Input

6 6
1 2
2 3
1 4
4 5
1 6
2 5
3 4
5 2
6 4
3 4
6 5


Output

3
2
3
2
3
2

Note

The first sample is depicted in the following figure.

<image>

After the first update, G contains all three possible edges. The result of a DFS is as follows: 

  * Let the starting vertex be 1. We have two choices of ordering the neighbors of 1, either [2, 3] or [3, 2]. 
    * If we choose the former, then we reach vertex 2. Regardless of the ordering of its neighbors, the next visited vertex will be 3. Thus, the spanning tree generated by this DFS will contain edges \{1, 2\} and \{2, 3\}, which does not equal to T. 
    * If we choose the latter, we obtain a spanning tree with edges \{1, 3\} and \{2, 3\}. 
Hence, there is no way of ordering the neighbors of vertices such that the DFS produces T, and subsequently 1 is not a good vertex. 
  * Let the starting vertex be 2. We have two choices of traversing its neighbors. If we visit 3 first, then the spanning tree will consist of edges \{2,3\} and \{1,3\}, which is not equal to T. If we, however, visit 1 first, then we can only continue to 3 from here, and the spanning tree will consist of edges \{1, 2\} and \{1,3\}, which equals to T. Hence, 2 is a good vertex. 
  * The case when we start in the vertex 3 is symmetrical to starting in 2, and hence 3 is a good vertex. 

Therefore, the answer is 2.

After the second update, the edge between 2 and 3 is removed, and G = T. It follows that the spanning tree generated by DFS will be always equal to T independent of the choice of the starting vertex. Thus, the answer is 3.

In the second sample, the set of good vertices after the corresponding query is: 

  * \{2, 3, 5\} 
  * \{3, 5\} 
  * \{3, 4, 5\} 
  * \{4, 5\} 
  * \{4, 5, 6\} 
  * \{5, 6\} 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5, inf = 1e9 + 5, L = 24;
int n, q, stt[maxn], ftt[maxn], ti, par[maxn][L], h[maxn];
int lzy[maxn << 2], mx;
vector<int> adj[maxn];
set<pair<int, int> > st;
pair<int, int> seg[maxn << 2];
pair<int, int> operator+(pair<int, int> a, pair<int, int> b) {
  if (a.first == b.first) return {a.first, a.second + b.second};
  if (a.first < b.first) return b;
  return a;
}
void build(int l = 0, int r = n, int id = 1) {
  seg[id] = {0, r - l};
  if (r - l == 1) {
    return;
  }
  int mid = l + r >> 1;
  build(l, mid, id << 1);
  build(mid, r, id << 1 | 1);
}
void shift(int id) {
  lzy[id << 1] += lzy[id];
  lzy[id << 1 | 1] += lzy[id];
  seg[id << 1].first += lzy[id];
  seg[id << 1 | 1].first += lzy[id];
  lzy[id] = 0;
}
void add(int ql, int qr, int val, int l = 0, int r = n, int id = 1) {
  if (max(ql, l) >= min(qr, r)) return;
  if (ql <= l && qr >= r) {
    seg[id].first += val;
    lzy[id] += val;
    return;
  }
  shift(id);
  int mid = l + r >> 1;
  add(ql, qr, val, l, mid, id << 1);
  add(ql, qr, val, mid, r, id << 1 | 1);
  seg[id] = seg[id << 1] + seg[id << 1 | 1];
}
void dfs(int v = 0, int p = -1) {
  par[v][0] = p;
  for (int i = 1; i < L; i++)
    par[v][i] = (par[v][i - 1] == -1 ? -1 : par[par[v][i - 1]][i - 1]);
  stt[v] = ti++;
  for (auto u : adj[v])
    if (u != p) h[u] = h[v] + 1, dfs(u, v);
  ftt[v] = ti;
}
int getpar(int v, int p) {
  for (int i = L - 1; i >= 0; i--) {
    if (p >= (1 << i)) {
      v = par[v][i];
      p -= (1 << i);
    }
    if (v == -1) break;
  }
  return v;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> q;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs();
  build();
  while (q--) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    bool b = 0;
    if (stt[x] < stt[y] && ftt[x] >= ftt[y]) {
      if (st.count({min(x, y), max(x, y)})) {
        mx--;
        add(stt[y], ftt[y], -1);
        add(0, n, -1);
        int d = h[y] - h[x];
        add(stt[getpar(y, d - 1)], ftt[getpar(y, d - 1)], 1);
        st.erase({min(x, y), max(x, y)});
      } else {
        mx++;
        add(stt[y], ftt[y], 1);
        add(0, n, 1);
        int d = h[y] - h[x];
        add(stt[getpar(y, d - 1)], ftt[getpar(y, d - 1)], -1);
        st.insert({min(x, y), max(x, y)});
      }
      b = 1;
    }
    swap(x, y);
    if (!b && stt[x] < stt[y] && ftt[x] >= ftt[y]) {
      if (st.count({min(x, y), max(x, y)})) {
        mx--;
        add(stt[y], ftt[y], -1);
        add(0, n, -1);
        int d = h[y] - h[x];
        add(stt[getpar(y, d - 1)], ftt[getpar(y, d - 1)], 1);
        st.erase({min(x, y), max(x, y)});
      } else {
        mx++;
        add(stt[y], ftt[y], 1);
        add(0, n, 1);
        int d = h[y] - h[x];
        add(stt[getpar(y, d - 1)], ftt[getpar(y, d - 1)], -1);
        st.insert({min(x, y), max(x, y)});
      }
      b = 1;
    }
    if (!b) {
      if (st.count({min(x, y), max(x, y)})) {
        mx--;
        add(stt[y], ftt[y], -1);
        add(stt[x], ftt[x], -1);
        st.erase({min(x, y), max(x, y)});
      } else {
        mx++;
        add(stt[y], ftt[y], 1);
        add(stt[x], ftt[x], 1);
        st.insert({min(x, y), max(x, y)});
      }
    }
    if (seg[1].first == mx)
      cout << seg[1].second << '\n';
    else
      cout << 0 << '\n';
  }
}

```