#include <bits/stdc++.h>
using namespace std;
const int N = 101010;
int nbnodes;
int Log(int n) {
  int p = 1;
  int i = 0;
  while (p < n) {
    p *= 2;
    i++;
  }
  return i - ((n == p) ? 0 : 1);
}
vector<int> adj[N];
vector<int> fils[N];
int pere[N];
int depth[N];
int p[N][17];
int cover[N];
bool marq[N];
int build(int node, int deep) {
  marq[node] = 1;
  depth[node] = deep;
  int sum = 1;
  for (int i = 0; i < adj[node].size(); i++) {
    int fr = adj[node][i];
    if (!marq[fr]) {
      fils[node].push_back(fr);
      pere[fr] = node;
      sum += build(fr, deep + 1);
    }
  }
  return cover[node] = sum;
}
void read() {
  scanf("%d", &nbnodes);
  for (int i = 0; i < nbnodes - 1; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
}
void compute_p() {
  for (int i = 1; i <= nbnodes; i++) p[i][0] = pere[i];
  for (int i = 1; i <= Log(nbnodes); i++) {
    for (int node = 1; node <= nbnodes; node++) {
      p[node][i] = p[p[node][i - 1]][i - 1];
    }
  }
}
int farfrom(int node, int dist) {
  int upper = 17;
  while (dist > 0) {
    if ((1 << upper) <= dist) {
      node = p[node][upper];
      dist -= (1 << upper);
    }
    upper--;
  }
  return node;
}
int least_commom_ancestor(int a, int b) {
  if (depth[a] != depth[b]) {
    if (depth[a] < depth[b]) swap(a, b);
    a = farfrom(a, depth[a] - depth[b]);
  }
  int jump = Log(nbnodes);
  while (jump >= 0) {
    if (p[a][jump] != p[b][jump]) {
      a = p[a][jump];
      b = p[b][jump];
    }
    jump--;
  }
  if (a == b) return a;
  return pere[a];
}
int nbequidistant(int a, int b) {
  if (a == b) return nbnodes;
  int LCA = least_commom_ancestor(a, b);
  int distA = depth[a] - depth[LCA], distB = depth[b] - depth[LCA];
  if (abs(distA - distB) % 2) return 0;
  if (distA > distB) {
    swap(a, b);
    swap(distA, distB);
  }
  int cible, marqA, marqB;
  if (distA == distB) {
    cible = LCA;
    marqA = farfrom(a, distA - 1);
    marqB = farfrom(b, distB - 1);
  } else {
    int m = (abs(distA + distB)) / 2;
    cible = farfrom(b, m);
    marqA = pere[cible];
    marqB = farfrom(b, m - 1);
  }
  int res = 0;
  if (pere[cible] == marqA)
    res += nbnodes - cover[cible];
  else
    res += cover[marqA];
  res += cover[marqB];
  return nbnodes - res;
}
int main() {
  read();
  pere[1] = 1;
  for (int i = 0; i < N; i++) marq[i] = 0;
  build(1, 0);
  compute_p();
  int nbq;
  scanf("%d", &nbq);
  while (nbq--) {
    int a, b;
    scanf("%d%d", &a, &b);
    int ans = nbequidistant(a, b);
    printf("%d\n", ans);
  }
}
