#include <bits/stdc++.h>
using namespace std;
const int MX = 1e5 + 2;
const long long INF = 1e18;
const long long md = 1e9 + 7;
int N, M, k;
int dep[MX];
vector<vector<int> > G(MX);
int dp[MX][20];
int sz[MX];
void calc(int x = 1, int p = 0) {
  sz[x] = 1;
  dp[x][0] = p;
  for (int i = 1; i < 19; i++) {
    dp[x][i] = dp[dp[x][i - 1]][i - 1];
  }
  for (int i = 0; i < G[x].size(); i++) {
    int ch = G[x][i];
    if (ch == p) continue;
    dep[ch] = dep[x] + 1;
    calc(ch, x);
    sz[x] += sz[ch];
  }
}
int lca(int a, int b) {
  if (a == b) return a;
  if (dep[a] > dep[b]) swap(a, b);
  int d = dep[b] - dep[a];
  for (int i = 0; i < 19; i++) {
    if ((1 << i) & d) b = dp[b][i];
  }
  if (a == b) return a;
  for (int i = 19; i >= 0; i--) {
    if (dp[a][i] != dp[b][i]) {
      a = dp[a][i];
      b = dp[b][i];
    }
  }
  return dp[a][0];
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i < N; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    G[a].push_back(b);
    G[b].push_back(a);
  }
  calc();
  scanf("%d", &M);
  while (M--) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (a == b)
      cout << N;
    else if (dep[a] == dep[b]) {
      int lc = lca(a, b);
      int cura = a, curb = b;
      int len = dep[cura] - dep[lc];
      for (int i = 0; i < 19; i++)
        if ((1 << i) & (len - 1)) cura = dp[cura][i];
      for (int i = 0; i < 19; i++)
        if ((1 << i) & (len - 1)) curb = dp[curb][i];
      int ans = -(sz[cura] + sz[curb]);
      cout << ans + N;
    } else if (abs(dep[a] - dep[b]) & 1)
      cout << 0;
    else {
      int lc = lca(a, b);
      if (dep[a] > dep[b]) swap(a, b);
      int cur = b;
      int k = (dep[b] + dep[a] - 2 * dep[lc]) / 2;
      int path = 0;
      for (int i = 0; i < 19; i++)
        if ((1 << i) & (k - 1)) cur = dp[cur][i];
      int ans = -sz[cur];
      cur = dp[cur][0];
      ans += sz[cur];
      cout << ans;
    }
    cout << "\n";
  }
  return 0;
}
