#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m;
int parent[maxn], lev[maxn], dp[maxn][25], sub_tree[maxn];
vector<int> G[maxn];
void dfs(int v, int par, int h) {
  lev[v] = h;
  parent[v] = par;
  dp[v][0] = par;
  sub_tree[v] = 1;
  for (int b : G[v]) {
    if (b == par) continue;
    dfs(b, v, h + 1);
    sub_tree[v] += sub_tree[b];
  }
}
int lift(int v, int p) {
  int d = p;
  int b = v;
  while (d) {
    int left_most = log2(d);
    d -= (1 << left_most);
    b = dp[b][left_most];
  }
  return b;
}
int lca(int a, int b) {
  if (a == b) return a;
  if (lev[a] > lev[b]) swap(a, b);
  int d = lev[b] - lev[a];
  b = lift(b, d);
  if (b == a) return a;
  for (int i = 20; i >= 0; i--) {
    if (dp[a][i] != -1 && dp[a][i] != dp[b][i]) {
      a = dp[a][i], b = dp[b][i];
    }
  }
  return parent[a];
}
int32_t main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b), G[b].push_back(a);
  }
  for (int i = 0; i < maxn; i++) {
    for (int j = 0; j < 25; j++) {
      dp[i][j] = -1;
    }
  }
  dfs(1, -1, 0);
  for (int j = 1; j <= 20; j++) {
    for (int i = 1; i <= n; i++) {
      if (dp[i][j - 1] != -1) {
        dp[i][j] = dp[dp[i][j - 1]][j - 1];
      }
    }
  }
  cin >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      cout << n << "\n";
      continue;
    }
    int anse = lca(a, b);
    int dis = lev[a] - lev[anse] + lev[b] - lev[anse];
    if (dis & 1) {
      cout << 0 << "\n";
      continue;
    }
    dis >>= 1;
    if (lev[a] < lev[b]) swap(a, b);
    int room = lift(a, dis);
    int ans = n;
    int child_of_a = lift(a, dis - 1);
    ans -= sub_tree[child_of_a];
    if (lev[b] <= lev[room]) {
      ans -= (n - sub_tree[room]);
    } else if (parent[lift(b, dis - 1)] == room) {
      int ver = lift(b, dis - 1);
      ans -= sub_tree[ver];
    } else {
      ans -= (n - sub_tree[room]);
    }
    cout << ans << "\n";
  }
  return 0;
}
