#include <bits/stdc++.h>
class Solution {
  int n;
  int timer;
  static constexpr int LOG = 18;
  std::vector<std::vector<int>> parent;
  std::vector<std::vector<int>> g;
  std::vector<int> tIn, tOut, depth;
  std::vector<int> subSize;
  void dfsParent(int u = 0, int p = 0) {
    if (u != p) g[u].erase(find(g[u].begin(), g[u].end(), p));
    tIn[u] = timer++;
    parent[u][0] = p;
    subSize[u] = 1;
    for (int i = 1; i < LOG; ++i)
      parent[u][i] = parent[parent[u][i - 1]][i - 1];
    for (int v : g[u]) {
      depth[v] = depth[u] + 1, dfsParent(v, u), subSize[u] += subSize[v];
    }
    tOut[u] = timer++;
  }
  bool isAncestorOf(int anc, int v) {
    return tIn[anc] <= tIn[v] and tOut[v] <= tOut[anc];
  }
  int LCA(int v, int u) {
    if (isAncestorOf(v, u))
      return v;
    else {
      for (int i = 17; i >= 0; --i) {
        if (not isAncestorOf(parent[v][i], u)) v = parent[v][i];
      }
    }
    return parent[v][0];
  }
  int getSubtreeWeightContainingTheChild(int u, int ch) {
    int l = 0, r = g[u].size();
    while (r - l > 1) {
      int m = r + l >> 1;
      if (tIn[g[u][m]] <= tIn[ch])
        l = m;
      else
        r = m;
    }
    return subSize[g[u][l]];
  }
  int jump(int u, int step) {
    for (int i = 17; i >= 0; --i) {
      if ((step >> i) & 1) u = parent[u][i];
    }
    return u;
  }
  int query(int v, int u) {
    if (v == u) return n;
    int lca = LCA(u, v);
    int len = depth[u] + depth[v] - 2 * depth[lca];
    if (len % 2)
      return 0;
    else {
      if (depth[u] == depth[v]) {
        return n - getSubtreeWeightContainingTheChild(lca, u) -
               getSubtreeWeightContainingTheChild(lca, v);
      } else {
        if (depth[u] > depth[v]) std::swap(u, v);
        int key = jump(v, len / 2);
        return subSize[key] - getSubtreeWeightContainingTheChild(key, v);
      }
    }
  }

 public:
  void run(std::istream &in, std::ostream &out) {
    in >> n;
    parent.assign(n, std::vector<int>(LOG));
    timer = 0;
    tIn.resize(n);
    tOut.resize(n);
    depth.resize(n);
    g.resize(n);
    subSize.resize(n);
    for (int i = 0, v, u; i < n - 1; ++i) {
      in >> u >> v;
      --u, --v;
      g[u].push_back(v), g[v].push_back(u);
    }
    dfsParent();
    int m;
    in >> m;
    while (m--) {
      int u, v;
      in >> u >> v;
      out << query(v - 1, u - 1) << '\n';
    }
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  Solution().run(std::cin, std::cout);
  return 0;
}
