#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10, maxl = 20;
int sp[maxn][maxl], h[maxn], sz[maxn], n, q;
int tin[maxn], tout[maxn], timer;
vector<int> adj[maxn];
int dfs(int u = 1, int par = 1, int hei = 0) {
  sp[u][0] = par;
  for (int i = 1; i < maxl; i++) sp[u][i] = sp[sp[u][i - 1]][i - 1];
  h[u] = hei;
  sz[u] = 1;
  tin[u] = timer++;
  for (int v : adj[u])
    if (v != par) sz[u] += dfs(v, u, hei + 1);
  tout[u] = timer++;
  return sz[u];
}
bool is_anc(int u, int v) { return tin[u] <= tin[v] && tout[u] >= tout[v]; }
int lca(int u, int v) {
  if (is_anc(v, u)) return v;
  if (is_anc(u, v)) return u;
  for (int i = maxl - 1; ~i; i--)
    if (!is_anc(sp[u][i], v)) u = sp[u][i];
  return sp[u][0];
}
int get_par(int u, int h) {
  for (int i = 0; i < maxl; i++)
    if (h >> i & 1) u = sp[u][i];
  return u;
}
int dis(int u, int v) { return h[u] + h[v] - 2 * h[lca(u, v)]; }
signed main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0, u, v; i < n - 1; i++)
    cin >> u >> v, adj[u].push_back(v), adj[v].push_back(u);
  dfs();
  cin >> q;
  while (q--) {
    int u, v;
    cin >> u >> v;
    if (u == v) {
      cout << n << '\n';
      continue;
    }
    int d = dis(u, v);
    if (d & 1) {
      cout << 0 << '\n';
      continue;
    }
    int x = lca(u, v), y;
    if (x == u)
      y = get_par(v, d / 2);
    else if (x == v)
      y = get_par(u, d / 2);
    else if (dis(u, x) > dis(v, x))
      y = get_par(u, d / 2);
    else
      y = get_par(v, d / 2);
    if (y == x) {
      for (int i = maxl - 1; ~i; i--) {
        if (!is_anc(sp[u][i], x)) u = sp[u][i];
        if (!is_anc(sp[v][i], x)) v = sp[v][i];
      }
      cout << n - sz[u] - sz[v] << '\n';
    }
    if (dis(u, x) < dis(v, x)) swap(u, v);
    if (dis(u, x) > dis(v, x)) {
      for (int i = maxl - 1; ~i; i--)
        if (!is_anc(sp[u][i], y)) u = sp[u][i];
      cout << sz[y] - sz[u] << '\n';
    }
  }
  return 0;
}
