#include <bits/stdc++.h>
int n, m, h;
std::vector<std::vector<int>> adj;
std::vector<bool> visited;
std::vector<int> height, cnt;
std::vector<std::vector<int>> parent;
void dfs(int x, int p) {
  visited[x] = true;
  cnt[x] = 1;
  height[x] = x == p ? 0 : 1 + height[p];
  parent[x].push_back(p);
  for (int i = 1; i < h; i++)
    parent[x].push_back(parent[parent[x][i - 1]][i - 1]);
  for (int n : adj[x]) {
    if (!visited[n]) {
      dfs(n, x);
      cnt[x] += cnt[n];
    }
  }
}
int lca(int x, int y) {
  ;
  ;
  ;
  if (height[x] < height[y]) std::swap(x, y);
  for (int i = h - 1; i >= 0; i--) {
    if (height[x] - (1 << i) >= height[y]) x = parent[x][i];
  };
  ;
  ;
  if (x == y) {
    ;
    ;
    ;
    return x;
  }
  for (int i = h - 1; i >= 0; i--) {
    if (parent[x][i] != parent[y][i]) {
      x = parent[x][i];
      y = parent[y][i];
    }
  };
  ;
  ;
  return parent[x][0];
}
int main() {
  std::cin >> n;
  h = ceil(log2(n));
  adj.assign(n, {});
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    std::cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  std::cin >> m;
  visited.assign(n, false);
  height.assign(n, -1);
  cnt.assign(n, -1);
  parent.assign(n, {});
  dfs(0, 0);
  std::cerr << "height";
  for (int x : height) std::cerr << " " << x;
  std::cerr << "\n";
  std::cerr << "cnt";
  for (int x : cnt) std::cerr << " " << x;
  std::cerr << "\n";
  for (int i = 0; i < m; i++) {
    int x, y;
    std::cin >> x >> y;
    x--, y--;
    if (height[x] < height[y]) std::swap(x, y);
    if (x == y) {
      std::cout << cnt[0] << "\n";
      continue;
    }
    int c = lca(x, y);
    int dist = height[x] + height[y] - 2 * height[c];
    if (dist % 2 == 1) {
      std::cout << "0\n";
    } else {
      int mid = x, premid = x;
      for (int i = 0; i < h; i++) {
        if ((dist / 2) & (1 << i)) mid = parent[mid][i];
        if ((dist / 2 - 1) & (1 << i)) premid = parent[premid][i];
      };
      ;
      ;
      int ans = cnt[mid] - cnt[premid];
      if (lca(y, mid) == mid) {
        int pre = y;
        for (int i = 0; i < h; i++)
          if ((height[y] - height[mid] - 1) & (1 << i)) pre = parent[pre][i];
        ;
        ;
        ;
        ans -= cnt[pre];
        ans += cnt[0] - cnt[mid];
      }
      std::cout << ans << "\n";
    }
  }
}
