#include <bits/stdc++.h>
using namespace std;
class Graph {
 private:
  vector<vector<int> > v;
  vector<vector<int> > dp;
  vector<int> tin, tout;
  vector<int> subtr;
  int n, m, tim, vis;

 public:
  Graph(int a) {
    n = a;
    v.assign(n, vector<int>(0, 0));
  }
  void addedge(int a, int b) {
    v[a].push_back(b);
    v[b].push_back(a);
  }
  void dfs(int idx, int par) {
    tin[idx] = tim++;
    dp[idx][0] = par;
    subtr[idx] = vis++;
    for (int i = 1; i <= m; i++) dp[idx][i] = dp[dp[idx][i - 1]][i - 1];
    for (int i = 0; i < v[idx].size(); i++) {
      int nxt = v[idx][i];
      if (nxt == par) continue;
      dfs(nxt, idx);
    }
    subtr[idx] = vis - subtr[idx];
    tout[idx] = tim++;
  }
  void build() {
    m = ceil(log2(n));
    dp.assign(n, vector<int>(m + 1, 0));
    tin.assign(n, 0);
    tout.assign(n, 0);
    subtr.assign(n, 0);
    tim = 0;
    vis = 0;
    dfs(1, 1);
  }
  bool is_ancestor(int a, int b) {
    return tin[a] <= tin[b] && tout[b] <= tout[a];
  }
  int dist(int u, int v) {
    int d = 0;
    for (int i = m; i >= 0; i--) {
      if (!is_ancestor(dp[v][i], u)) {
        v = dp[v][i];
        d += pow(2, i);
      }
    }
    d++;
    return d;
  }
  int ans(int u, int rem) {
    while (rem) {
      int i = 0;
      while (pow(2, i) <= rem) i++;
      rem -= pow(2, i - 1);
      u = dp[u][i - 1];
    }
    return subtr[dp[u][0]] - subtr[u];
  }
  int query(int a, int b) {
    if (a == b) return n - 1;
    if (is_ancestor(a, b)) {
      int d = dist(a, b);
      if (d & 1) return 0;
      return ans(b, d / 2 - 1);
    }
    if (is_ancestor(b, a)) {
      int d = dist(b, a);
      if (d & 1) return 0;
      return ans(a, d / 2 - 1);
    }
    int x = dist(b, a);
    int y = dist(a, b);
    int t_dist = x + y;
    if (t_dist & 1) return 0;
    t_dist /= 2;
    if (x > t_dist) return ans(a, t_dist - 1);
    if (x < t_dist) return ans(b, t_dist - 1);
    for (int i = m; i >= 0; i--) {
      if (!is_ancestor(dp[a][i], b)) a = dp[a][i];
    }
    for (int i = m; i >= 0; i--) {
      if (!is_ancestor(dp[b][i], a)) b = dp[b][i];
    }
    return n - 1 - subtr[a] - subtr[b];
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, a, b;
  cin >> n;
  Graph g(n + 1);
  while (--n) {
    cin >> a >> b;
    g.addedge(a, b);
  }
  g.build();
  cin >> n;
  while (n--) {
    cin >> a >> b;
    cout << g.query(a, b) << endl;
  }
}
