#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
int dp[20][100005], depth[100005], vis[2 * 100005], subsz[100005 + 5];
void dfs1(int u, int p) {
  subsz[u] = 1;
  vis[u] = 1;
  for (int i = 0; i < adj[u].size(); i++) {
    int k = adj[u][i];
    if (vis[k] || k == p) continue;
    dfs1(k, u);
    subsz[u] += subsz[k];
  }
}
int nd(int r, int u) {
  int diff = depth[u] - depth[r];
  diff--;
  int i;
  int v = u;
  for (i = 0; i <= 17; i++) {
    if (diff & (1 << i)) {
      v = dp[i][v];
    }
  }
  return v;
}
void dfs(int u, int p, int h) {
  dp[0][u] = p;
  depth[u] = h;
  for (int i = 0; i < adj[u].size(); i++)
    if (adj[u][i] == p)
      continue;
    else
      dfs(adj[u][i], u, h + 1);
}
void pre(int n) {
  for (int i = 1; (1 << i) <= n + 1; i++)
    for (int j = 1; j <= n; j++) dp[i][j] = dp[i - 1][dp[i - 1][j]];
}
int lca(int u, int v) {
  if (depth[u] < depth[v]) swap(u, v);
  int diff = depth[u] - depth[v];
  for (int i = 0; i <= 17; i++)
    if ((diff >> i) & 1) u = dp[i][u];
  if (u == v) return u;
  for (int i = 17; i >= 0; i--)
    if (dp[i][u] != dp[i][v]) {
      u = dp[i][u];
      v = dp[i][v];
    }
  return dp[0][u];
}
int dist(int u, int v) { return depth[u] + depth[v] - 2 * depth[lca(u, v)]; }
int find(int u, int v, int l) {
  if (depth[u] < depth[v]) swap(u, v);
  int jump = u, d1, d2, low = u, current = u, last = u;
  int cntr = 0;
  for (int i = 0; i <= 17; i++) {
    if (depth[jump] < depth[l] || jump == 0) {
      current = last;
      i = -1;
    }
    d1 = dist(jump, u);
    d2 = dist(jump, v);
    if (d1 == d2)
      return jump;
    else if (d1 > d2) {
      current = last;
      jump = last;
      i = -1;
    } else if (d1 < d2) {
      last = jump;
      jump = dp[i][current];
    }
  }
}
int main() {
  int n, q;
  cin >> n;
  int i;
  for (i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 0, 0);
  pre(n);
  dfs1(1, 0);
  cin >> q;
  while (q--) {
    int u, v;
    int ans = 0;
    cin >> u >> v;
    int l = lca(u, v);
    int d1 = dist(u, l);
    int d2 = dist(v, l);
    int dist = depth[u] + depth[v] - 2 * depth[l];
    if (1 & dist) {
      cout << "0\n";
      continue;
    } else if (d1 == d2) {
      ans = n;
      ans -= subsz[nd(l, u)];
      ans -= subsz[nd(l, v)];
    } else {
      int ret = find(u, v, l);
      if (depth[u] < depth[v]) swap(u, v);
      int minus = 0;
      minus = subsz[nd(ret, u)];
      ans = subsz[ret] - minus;
    }
    cout << ans << endl;
  }
  return 0;
}
