#include <bits/stdc++.h>
using namespace std;
const int MAXN = 500100, MAXK = 30;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long double PI = asin(1) * 2;
int n, m;
int par[MAXN][MAXK];
int dep[MAXN];
vector<int> adj[MAXN];
int sz[MAXN];
void dfs(int v, int p) {
  for (int i = (1); i <= (MAXK - 1); i++) par[v][i] = par[par[v][i - 1]][i - 1];
  for (int u : adj[v]) {
    if (u == p) continue;
    par[u][0] = v;
    dep[u] = dep[v] + 1;
    dfs(u, v);
    sz[v] += sz[u];
  }
  sz[v]++;
}
int lca(int u, int v) {
  if (u == v) return u;
  if (dep[u] < dep[v]) swap(u, v);
  int d = dep[u] - dep[v];
  for (int i = (0); i <= (MAXK - 1); i++)
    if (d & (1 << i)) u = par[u][i];
  if (u == v) return u;
  for (int i = MAXK - 1; i >= 0; i--)
    if (par[u][i] != par[v][i]) u = par[u][i], v = par[v][i];
  return par[u][0];
}
bool isAncestor(int u, int v) { return lca(u, v) == v; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int O = (1); O <= ((n - 1)); O++) {
    int u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, -1);
  cin >> m;
  for (int O = (1); O <= ((m)); O++) {
    int u, v;
    cin >> u >> v;
    if (u == v) {
      cout << n << "\n";
      continue;
    }
    int dist = dep[v] + dep[u] - 2 * dep[lca(v, u)];
    if (dist % 2 == 1) {
      cout << 0 << "\n";
      continue;
    }
    if (dep[v] > dep[u]) swap(u, v);
    int d = dist / 2;
    int ans = 0;
    if (dep[u] == dep[v]) {
      ans = n;
      int k = u;
      d--;
      for (int i = (0); i <= (MAXK - 1); i++)
        if (d & (1 << i)) k = par[k][i];
      ans -= sz[k];
      k = v;
      for (int i = (0); i <= (MAXK - 1); i++)
        if (d & (1 << i)) k = par[k][i];
      ans -= sz[k];
    } else {
      int k = u;
      for (int i = (0); i <= (MAXK - 1); i++)
        if (d & (1 << i)) k = par[k][i];
      ans = sz[k];
      k = u;
      d--;
      for (int i = (0); i <= (MAXK - 1); i++)
        if (d & (1 << i)) k = par[k][i];
      ans -= sz[k];
    }
    cout << ans << "\n";
  }
  return 0;
}
