#include <bits/stdc++.h>
using namespace std;
int pa[1 << 20];
int dis[1 << 20];
int dp[1 << 18][22];
int dp2[1 << 18];
vector<int> v[1 << 20];
int n;
int tmp = 0;
int DFS(int head, int p, int d, int h = 0) {
  pa[head] = p;
  dis[head] = d;
  dp[head][0] = p;
  dp2[head]++;
  for (int i = 0; i < v[head].size(); i++) {
    int to = v[head][i];
    if (to != p) {
      DFS(to, head, d + 1);
      dp2[head] += dp2[to];
    }
  }
  return h;
}
void pre() {
  for (int i = 1; i <= 20; i++) {
    for (int j = 1; j <= n; j++) {
      dp[j][i] = dp[dp[j][i - 1]][i - 1];
    }
  }
}
int lca(int u, int v) {
  tmp = 0;
  if (dis[v] > dis[u]) {
    swap(u, v);
  }
  int diff = dis[u] - dis[v];
  for (int i = 20; i >= 0; i--) {
    if ((1 << i) <= diff) {
      u = dp[u][i], diff -= (1 << i);
    }
  }
  if (u == v) return u;
  for (int i = 20; i >= 0; i--) {
    if (dp[u][i] != dp[v][i]) {
      u = dp[u][i];
      v = dp[v][i];
    }
  }
  tmp = dp2[u] + dp2[v];
  return dp[u][0];
}
int main() {
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  DFS(1, -1, 0, 0);
  pre();
  int q;
  cin >> q;
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    int l = lca(x, y);
    if (dis[x] == dis[y]) {
      printf("%d\n", n - tmp);
    } else {
      if (dis[x] - dis[l] < dis[y] - dis[l]) swap(x, y);
      int tmp = dis[x] + dis[y] - 2 * dis[l];
      if (tmp % 2 != 0) {
        printf("%d\n", 0);
        continue;
      }
      tmp /= 2;
      tmp--;
      for (int i = 20; i >= 0; i--) {
        if ((1 << i) <= tmp) {
          tmp -= (1 << i);
          x = dp[x][i];
        }
      }
      printf("%d\n", dp2[dp[x][0]] - dp2[x]);
    }
  }
}
