#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
vector<vector<int> > G;
int depth[100005], stsize[100005], P[100005][18], N;
int getLCA(int u, int v) {
  if (depth[v] > depth[u]) swap(u, v);
  int log;
  for (log = 1; 1 << log <= depth[u]; ++log)
    ;
  --log;
  for (int i = log; i >= 0; --i)
    if (depth[u] - (1 << i) >= depth[v]) u = P[u][i];
  if (u == v) return u;
  for (int i = log; i >= 0; --i)
    if (P[u][i] != -1 && P[u][i] != P[v][i]) u = P[u][i], v = P[v][i];
  return P[u][0];
}
void dfs(int u, int prev, int level) {
  depth[u] = level;
  P[u][0] = prev;
  stsize[u] = 1;
  for (int i = 0; i < G[u].size(); ++i) {
    if (prev == G[u][i]) continue;
    dfs(G[u][i], u, level + 1);
    stsize[u] += stsize[G[u][i]];
  }
}
void init() {
  int LG;
  for (LG = 0; 1 << LG <= N; ++LG)
    ;
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j < LG; ++j) P[i][j] = -1;
  }
  dfs(1, -1, 0);
  for (int j = 1; j < LG; ++j) {
    for (int i = 0; i <= N; ++i) {
      if (P[i][j - 1] != -1) P[i][j] = P[P[i][j - 1]][j - 1];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;
  int a, b, q, dist, lca;
  cin >> N;
  G.resize(N + 1);
  for (int i = 1; i < N; ++i) {
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  init();
  cin >> q;
  while (q--) {
    cin >> a >> b;
    lca = getLCA(a, b);
    dist = depth[a] + depth[b] - 2 * depth[lca];
    if (a == b)
      cout << N << '\n';
    else if (dist % 2) {
      cout << 0 << '\n';
    } else {
      if (depth[a] < depth[b]) swap(a, b);
      int tempdist = dist / 2;
      if (tempdist % 2 == 0) --tempdist, a = P[a][0];
      int lg;
      for (lg = 0; (1 << lg) <= tempdist; ++lg)
        ;
      --lg;
      for (int i = lg; i > 0; --i) {
        if (tempdist & (1 << i)) {
          tempdist - (1 << i);
          a = P[a][i];
        }
      }
      int meet = P[a][0];
      if (depth[meet] > depth[lca]) {
        cout << stsize[meet] - stsize[a] << '\n';
      } else {
        tempdist = dist / 2;
        if (tempdist % 2 == 0) --tempdist, b = P[b][0];
        for (lg = 0; (1 << lg) <= tempdist; ++lg)
          ;
        --lg;
        for (int i = lg; i > 0; --i) {
          if (tempdist & (1 << i)) {
            tempdist - (1 << i);
            b = P[b][i];
          }
        }
        if (lca == meet)
          cout << N - stsize[a] - stsize[b] << '\n';
        else
          cout << stsize[meet] - stsize[b] - stsize[a] << '\n';
      }
    }
  }
  return 0;
}
