#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;
const int Nmax = 100001;
const int Lmax = 18;
int N, Q;
int BadBranchX, BadBranchY;
int Sol;
int SubTreeSize[Nmax];
VI Graph[Nmax];
void Read();
int GetClosest(int x, int y);
int Euler[Nmax << 1], Ind[Nmax], Depth[Nmax << 1], Log[Nmax << 1], K, level,
    RMQ[Lmax][Nmax << 1], DP[Lmax][Nmax];
bool Visited[Nmax];
void DFS(int node);
void LCA();
int LCA(int x, int y);
int Distance(int x, int y, int lca);
int GetPadre(int k, int x);
int main() {
  Read();
  LCA();
  cin >> Q;
  for (int A, B, Mid; Q--;) {
    cin >> A >> B;
    Sol = 0;
    Mid = GetClosest(A, B);
    cout << Sol << '\n';
  }
}
void Read() {
  cin >> N;
  for (int i = 1, a, b; i < N; ++i) {
    cin >> a >> b;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }
  for (int i = 2; i < Nmax << 1; ++i) Log[i] = Log[i >> 1] + 1;
};
int GetClosest(int x, int y) {
  int MID;
  int lca = LCA(x, y);
  int D = Distance(x, y, lca);
  if (D % 2 == 1) return 0;
  if (Depth[Ind[x]] == Depth[Ind[y]]) {
    BadBranchX = GetPadre((D / 2) - 1, x);
    BadBranchY = GetPadre((D / 2) - 1, y);
    Sol = N;
    Sol -= SubTreeSize[BadBranchX];
    Sol -= SubTreeSize[BadBranchY];
    return lca;
  }
  if (Depth[Ind[x]] > Depth[Ind[y]]) {
    MID = GetPadre(D / 2, x);
    BadBranchX = GetPadre((D / 2) - 1, x);
    BadBranchY = GetPadre((D / 2) + 1, x);
    Sol = N;
    Sol -= SubTreeSize[BadBranchX];
    Sol -= (N - SubTreeSize[MID]);
    return MID;
  }
  if (Depth[Ind[x]] < Depth[Ind[y]]) {
    MID = GetPadre(D / 2, y);
    BadBranchX = GetPadre((D / 2) + 1, y);
    BadBranchY = GetPadre((D / 2) - 1, y);
    Sol = N;
    Sol -= SubTreeSize[BadBranchY];
    Sol -= (N - SubTreeSize[MID]);
    return MID;
  }
};
void DFS(int node) {
  SubTreeSize[node] = 1;
  Visited[node] = 1;
  Euler[++K] = node;
  Depth[K] = ++level;
  Ind[node] = K;
  for (const int& next : Graph[node])
    if (Visited[next] == 0) {
      DP[0][next] = node;
      DFS(next);
      SubTreeSize[node] += SubTreeSize[next];
      Euler[++K] = node;
      Depth[K] = level;
    }
  --level;
};
void LCA() {
  DFS(1);
  for (int i = 1; i <= K; ++i) RMQ[0][i] = i;
  for (int i = 1, k; (1 << i) <= K; ++i)
    for (int j = 1; j + (1 << i) <= K + 1; ++j) {
      k = j + (1 << (i - 1));
      if (Depth[RMQ[i - 1][j]] <= Depth[RMQ[i - 1][k]])
        RMQ[i][j] = RMQ[i - 1][j];
      else
        RMQ[i][j] = RMQ[i - 1][k];
    }
  for (int i = 1; i < Lmax; ++i)
    for (int j = 1; j <= N; ++j) DP[i][j] = DP[i - 1][DP[i - 1][j]];
};
int LCA(int x, int y) {
  int p1 = Ind[x], p2 = Ind[y], k;
  if (p1 > p2) swap(p1, p2);
  k = Log[p2 - p1 + 1];
  p2 = p2 - (1 << k) + 1;
  if (Depth[RMQ[k][p1]] <= Depth[RMQ[k][p2]]) return Euler[RMQ[k][p1]];
  return Euler[RMQ[k][p2]];
};
int Distance(int x, int y, int lca) {
  x = Depth[Ind[x]];
  y = Depth[Ind[y]];
  lca = Depth[Ind[lca]];
  return (x + y - 2 * lca);
};
int GetPadre(int k, int x) {
  for (int i = 0; i < Lmax; ++i)
    if (k & (1 << i)) x = DP[i][x];
  return x;
};
