#include <bits/stdc++.h>
using namespace std;
long long int n, q, sub[100005], L[100005], S[100005][30], par[100005],
    lg[100005];
vector<long long int> G[100005];
void clean() {
  for (long long int i = 0; i < 100005; i++) {
    L[i] = 0;
    G[i].clear();
    par[i] = i;
    for (long long int j = 0; j < 30; j++) S[i][j] = -1;
  }
}
void dfs(long long int u, long long int p, long long int lvl) {
  sub[u] = 1;
  L[u] = lvl;
  long long int sz = G[u].size();
  for (long long int i = 0; i < sz; i++) {
    long long int v = G[u][i];
    if (v == p) continue;
    par[v] = u;
    dfs(v, u, lvl + 1);
    sub[u] += sub[v];
  }
  return;
}
void BuildLca() {
  for (long long int i = 1; i <= n; i++) S[i][0] = par[i];
  for (long long int j = 1; j < 30; j++) {
    for (long long int i = 1; i <= n; i++) {
      if (S[i][j - 1] != -1) {
        S[i][j] = S[S[i][j - 1]][j - 1];
      }
    }
  }
  for (long long int i = 2; i <= n + 3; i++) lg[i] = lg[i / 2] + 1;
}
long long int LCA(long long int a, long long int b) {
  if (L[a] < L[b]) swap(a, b);
  long long int Log = lg[L[a]];
  for (long long int i = Log; i >= 0; i--) {
    if (L[a] - (1 << i) >= L[b]) {
      a = S[a][i];
    }
  }
  if (a == b) return a;
  for (long long int i = Log; i >= 0; i--) {
    if (S[a][i] != -1 && S[a][i] != S[b][i]) {
      a = S[a][i];
      b = S[b][i];
    }
  }
  return S[a][0];
}
long long int kth_node(long long int node, long long int k) {
  for (long long int i = 29; i >= 0; i--) {
    long long int v = 1 << i;
    if (v <= k) {
      node = S[node][i];
      k -= v;
    }
  }
  return node;
}
int main() {
  clean();
  scanf("%lld", &n);
  for (long long int i = 1; i < n; i++) {
    long long int a, b;
    scanf("%lld%lld", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  dfs(1, -1, 1);
  BuildLca();
  scanf("%lld", &q);
  while (q--) {
    long long int x, y;
    scanf("%lld%lld", &x, &y);
    long long int lca = LCA(x, y);
    long long int val_x = L[x] - L[lca], val_y = L[y] - L[lca],
                  mot = val_x + val_y;
    if (mot == 0) {
      printf("%lld\n", n);
      continue;
    }
    if (mot % 2 == 1) {
      printf("0\n");
      continue;
    }
    long long int ans;
    if (val_x == val_y) {
      ans = sub[1] - sub[kth_node(x, val_x - 1)] - sub[kth_node(y, val_y - 1)];
    } else if (val_x > val_y) {
      long long int div = (mot / 2);
      ans = sub[kth_node(x, div)] - sub[kth_node(x, div - 1)];
    } else {
      long long int div = (mot / 2);
      ans = sub[kth_node(y, div)] - sub[kth_node(y, div - 1)];
    }
    printf("%lld\n", ans);
  }
}
