#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 1;
int n, m, hi[maxn], dp[maxn], par[maxn][21];
vector<int> v[maxn];
void dfs(int x, int p = 0) {
  par[x][0] = p;
  hi[x] = hi[p] + 1;
  for (int i = 0; i < v[x].size(); i++) {
    int child = v[x][i];
    if (child != p) dfs(child, x);
  }
  dp[x]++;
  dp[p] += dp[x];
}
int gtpr(int x, int k) {
  for (int j = 0; j < 21; j++)
    if ((1 << j) & k) x = par[x][j];
  return x;
}
int lca(int x, int y) {
  if (hi[x] == hi[y]) {
    for (int j = 20; j >= 0; j--)
      if (par[x][j] != par[y][j]) {
        x = par[x][j];
        y = par[y][j];
      }
    return (n - dp[x] - dp[y]);
  }
  if (hi[x] < hi[y]) swap(x, y);
  int k = hi[x] - hi[y];
  int a = x, b = y;
  a = gtpr(x, k);
  if (a != b) {
    for (int j = 20; j >= 0; j--)
      if (par[a][j] != par[b][j]) {
        a = par[a][j];
        b = par[b][j];
      }
    a = par[a][0];
  }
  int dis = hi[x] + hi[y] - 2 * (hi[a]);
  if (dis & 1)
    return 0;
  else {
    dis /= 2;
    int ans = gtpr(x, dis);
    int kam = gtpr(x, dis - 1);
    return dp[ans] - dp[kam];
  }
}
int main() {
  cin >> n;
  int a, b;
  for (int i = 1; i < n; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  dfs(1);
  for (int j = 1; j < 21; j++)
    for (int i = 1; i <= n; i++) par[i][j] = par[par[i][j - 1]][j - 1];
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> a >> b;
    if (a == b)
      cout << n << endl;
    else
      cout << lca(a, b) << endl;
  }
}
