#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5, LOG = 22;
vector<long long> g[N];
long long child[N], p[N][LOG], d[N];
void dfs(long long node, long long par) {
  child[node] = 1;
  for (long long v : g[node])
    if (v != par) {
      d[v] = d[node] + 1;
      p[v][0] = node;
      dfs(v, node);
      child[node] += child[v];
    }
}
void pre() {
  for (long long k = 1; k < LOG; k++) {
    for (long long i = 1; i < N; i++) p[i][k] = p[p[i][k - 1]][k - 1];
  }
}
long long walk(long long node, long long k) {
  for (long long i = 0; i < LOG; i++)
    if (k & (1LL << i)) {
      node = p[node][i];
    }
  return node;
}
long long lca(long long u, long long v) {
  if (d[u] > d[v]) {
    u = walk(u, d[u] - d[v]);
  }
  if (d[u] < d[v]) {
    v = walk(v, d[v] - d[u]);
  }
  if (u == v) return u;
  for (long long i = LOG - 1; i >= 0; i--)
    if (p[u][i] != p[v][i]) {
      u = p[u][i];
      v = p[v][i];
    }
  return p[u][0];
}
long long distance(long long u, long long v) {
  return d[u] + d[v] - 2 * d[lca(u, v)];
}
int32_t main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  ;
  long long n;
  cin >> n;
  for (long long i = 1; i <= n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, -1);
  pre();
  long long q, u, v;
  cin >> q;
  while (q--) {
    cin >> u >> v;
    if (d[u] < d[v]) swap(u, v);
    long long dis = distance(u, v);
    if (dis % 2 == 1) {
      cout << 0 << "\n";
      continue;
    }
    long long mid_node = walk(u, dis / 2);
    long long lc = lca(u, v);
    long long dis1 = d[u] - d[mid_node];
    long long dis2 = d[v] - d[mid_node];
    long long ans = 0;
    if (dis1 == dis2) {
      ans = n - child[walk(u, dis / 2 - 1)] - child[walk(v, dis / 2 - 1)];
    } else {
      ans = child[mid_node] - child[walk(u, dis / 2 - 1)];
    }
    cout << ans << "\n";
  }
}
