#include <bits/stdc++.h>
using namespace std;
int fa[100007][25];
int dp[100007];
int siz[100007];
int n, m;
vector<int> e[100007];
void add(int u, int v) {
  e[u].push_back(v);
  e[v].push_back(u);
}
void dfs(int u, int p) {
  if (p == -1) dp[u] = 1;
  siz[u] = 1;
  for (int i = 1; i < 21; i++) fa[u][i] = fa[fa[u][i - 1]][i - 1];
  for (int i = 0; i < e[u].size(); i++) {
    int v = e[u][i];
    if (v == p) continue;
    dp[v] = dp[u] + 1;
    fa[v][0] = u;
    dfs(v, u);
    siz[u] += siz[v];
  }
}
int lca(int u, int v) {
  if (dp[u] < dp[v]) swap(u, v);
  for (int i = 20; i >= 0; i--) {
    if (dp[fa[u][i]] >= dp[v]) u = fa[u][i];
    if (u == v) return u;
  }
  for (int i = 20; i >= 0; i--)
    if (fa[u][i] != fa[v][i]) {
      v = fa[v][i];
      u = fa[u][i];
    }
  return fa[u][0];
}
void init() {
  for (int i = 0; i < 100007; i++) e[i].clear();
}
int main() {
  while (~scanf("%d", &n)) {
    init();
    for (int i = 1; i < n; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      add(x, y);
    }
    dfs(1, -1);
    scanf("%d", &m);
    while (m--) {
      int x, y, ans;
      scanf("%d%d", &x, &y);
      if (x == y) {
        printf("%d\n", n);
        continue;
      }
      int f = lca(x, y);
      if (dp[x] > dp[y]) swap(x, y);
      if (f == x) {
        int l = dp[y] - dp[x];
        if (l & 1)
          ans = 0;
        else {
          l /= 2;
          l--;
          int fy = y, fx;
          int num = 0;
          while (l) {
            if (l & 1) fy = fa[fy][num];
            num++;
            l >>= 1;
          }
          fx = fa[fy][0];
          ans = siz[fx] - siz[fy];
        }
      } else {
        int l = dp[x] + dp[y] - 2 * dp[f];
        if (l & 1)
          ans = 0;
        else {
          l /= 2;
          l--;
          int ll = l;
          int fy = y, fx;
          int num = 0;
          while (l) {
            if (l & 1) fy = fa[fy][num];
            num++;
            l >>= 1;
          }
          if (dp[x] == dp[y]) {
            fx = x;
            int num = 0;
            while (ll) {
              if (ll & 1) fx = fa[fx][num];
              num++;
              ll >>= 1;
            }
            ans = n - siz[fx] - siz[fy];
          } else {
            fx = fa[fy][0];
            ans = siz[fx] - siz[fy];
          }
        }
      }
      printf("%d\n", ans);
    }
  }
}
