#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int LG = 20;
int n, q, dp[LG + 5][maxn], d[maxn], sz[maxn];
vector<int> g[maxn];
int get_parlc(int v, int dis) {
  for (int i = LG - 1; i >= 0; i--)
    if (dis & (1 << i)) v = dp[i][v];
  return v;
}
int lca(int v, int u) {
  if (d[v] < d[u]) swap(v, u);
  v = get_parlc(v, d[v] - d[u]);
  if (v == u) return v;
  for (int i = LG - 1; i >= 0; i--)
    if (dp[i][v] != dp[i][u]) {
      v = dp[i][v];
      u = dp[i][u];
    }
  return dp[0][v];
}
void dfs(int v, int par) {
  for (int i = 1; i < LG; i++) dp[i][v] = dp[i - 1][dp[i - 1][v]];
  for (auto i : g[v])
    if (i != par) {
      d[i] = d[v] + 1;
      dp[0][i] = v;
      dfs(i, v);
      sz[v] = sz[v] + sz[i];
    }
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  for (int i = 1; i <= n; i++) sz[i] = 1;
  dfs(1, 0);
  cin >> q;
  while (q--) {
    int v, u;
    cin >> v >> u;
    int lc = lca(u, v);
    if (d[v] < d[u]) swap(u, v);
    if (d[u] == d[v])
      cout << n - sz[get_parlc(v, d[v] - d[lc] - 1)] -
                  sz[get_parlc(u, d[u] - d[lc] - 1)];
    else {
      int x = d[v] - d[u];
      if (x % 2)
        cout << 0;
      else
        cout << sz[get_parlc(v, d[v] - d[lc] - x / 2)] -
                    sz[get_parlc(v, d[v] - d[lc] - x / 2 - 1)];
    }
    cout << '\n';
  }
  return 0;
}
