#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, N2 = 6, K = 20;
int n, m, d[N], st[N], ft[N], t, c[N], up[N][K];
vector<int> adj[N];
void dfs(int u, int p = 0, int dp = 0) {
  d[u] = dp;
  st[u] = t++;
  c[u] = 1;
  up[u][0] = p;
  for (int i = 1; i < K; i++) {
    up[u][i] = up[up[u][i - 1]][i - 1];
  }
  for (auto v : adj[u]) {
    if (v != p) {
      dfs(v, u, dp + 1);
      c[u] += c[v];
    }
  }
  ft[u] = t++;
}
bool is_ancestor(int u, int v) { return st[u] <= st[v] && ft[u] >= ft[v]; }
int go_up(int u, int v) {
  for (int i = K - 1; i >= 0; i--) {
    if (!is_ancestor(up[u][i], v)) {
      u = up[u][i];
    }
  }
  return u;
}
int lca(int u, int v) {
  if (is_ancestor(u, v)) {
    return u;
  }
  if (is_ancestor(v, u)) {
    return v;
  }
  return up[go_up(u, v)][0];
}
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(0);
  cin >> m;
  while (m--) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    int l = lca(x, y);
    int ans = 0;
    if (x == y) {
      ans = n;
    } else if (d[l] - d[x] == d[l] - d[y]) {
      x = go_up(x, l);
      y = go_up(y, l);
      ans = n - c[x] - c[y];
    } else {
      if (d[x] < d[y]) {
        swap(x, y);
      }
      int to = x;
      int dist = d[x] + d[y] - 2 * d[l];
      if (dist & 1) {
        ans = 0;
      } else {
        dist >>= 1;
        for (int i = K - 1; i >= 0; i--) {
          if (d[x] - d[up[to][i]] < dist) {
            to = up[to][i];
          }
        }
        int mid = up[to][0];
        ans = c[mid] - c[to];
      }
    }
    cout << ans << endl;
  }
  return 0;
}
