#include <bits/stdc++.h>
using namespace std;
class Tree {
 public:
  Tree(int nVertices) : nVertices(nVertices), edgesFrom(nVertices) {
    int powerOfTwo = 1;
    log2vertices = 0;
    while (powerOfTwo < nVertices) {
      powerOfTwo *= 2;
      log2vertices++;
    }
  }
  void addEdge(int v1, int v2) {
    edgesList.push_back({v1, v2});
    edgesFrom[v1].push_back(v2);
    edgesFrom[v2].push_back(v1);
  }
  void makeRooted(int root) {
    parents = vector<vector<int>>(nVertices, vector<int>(log2vertices));
    depth = vector<int>(nVertices);
    timeIn = vector<int>(nVertices);
    timeOut = vector<int>(nVertices);
    currentTime = 0;
    depthFirstProcess(root, root, 0);
    assert(currentTime == nVertices);
    for (int j = 0; j < nVertices; ++j)
      for (int i = 1; i < log2vertices; ++i)
        parents[j][i] = parents[parents[j][i - 1]][i - 1];
  }
  int degree(int v) const { return edgesFrom[v].size(); }
  int getAncestor(int v, int levels = 1) const {
    if (levels == 0) return v;
    int logOfLevelsUp = log2vertices;
    while ((levels & (1 << logOfLevelsUp)) == 0) logOfLevelsUp--;
    return getAncestor(parents[v][logOfLevelsUp],
                       levels - (1 << logOfLevelsUp));
  }
  int lca(int v1, int v2) const {
    if (depth[v1] < depth[v2]) swap(v1, v2);
    int v1ancestor = getAncestor(v1, depth[v1] - depth[v2]);
    assert(depth[v1ancestor] == depth[v2]);
    if (v1ancestor == v2) return v2;
    int l = 0;
    int r = nVertices;
    while (r - l > 1) {
      int c = (l + r) / 2;
      if (getAncestor(v1ancestor, c) == getAncestor(v2, c))
        r = c;
      else
        l = c;
    }
    return getAncestor(v2, r);
  }
  int distance(int v1, int v2) const {
    int l = lca(v1, v2);
    return (depth[v1] + depth[v2] - 2 * depth[l]);
  }
  int subtreeSize(int v) const { return timeOut[v] - timeIn[v]; }
  int getDepth(int v) const { return depth[v]; }

 private:
  void depthFirstProcess(int v, int parent, int currDepth) {
    timeIn[v] = currentTime;
    currentTime++;
    parents[v][0] = parent;
    depth[v] = currDepth;
    for (int neighbour : edgesFrom[v])
      if (neighbour != parent) depthFirstProcess(neighbour, v, currDepth + 1);
    timeOut[v] = currentTime;
  }

 private:
  int nVertices;
  int log2vertices;
  vector<pair<int, int>> edgesList;
  vector<vector<int>> edgesFrom;
  vector<vector<int>> parents;
  vector<int> timeIn, timeOut;
  int currentTime;
  vector<int> depth;
};
int main() {
  cin.sync_with_stdio(false);
  int nRooms;
  cin >> nRooms;
  Tree rooms(nRooms);
  for (int i = 0; i < nRooms - 1; ++i) {
    int a, b;
    cin >> a >> b;
    rooms.addEdge(a - 1, b - 1);
  }
  rooms.makeRooted(0);
  int nQueries;
  cin >> nQueries;
  for (int i = 0; i < nQueries; ++i) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a == b) {
      cout << nRooms << '\n';
      continue;
    }
    int dist = rooms.distance(a, b);
    if (dist % 2 == 1) {
      cout << 0 << '\n';
      continue;
    }
    int dHalf = dist / 2;
    int da = rooms.getDepth(a);
    int db = rooms.getDepth(b);
    if (da == db) {
      int aPredec = rooms.getAncestor(a, dHalf - 1);
      int bPredec = rooms.getAncestor(b, dHalf - 1);
      cout << nRooms - rooms.subtreeSize(aPredec) - rooms.subtreeSize(bPredec)
           << '\n';
      continue;
    }
    if (da < db) {
      swap(a, b);
      swap(da, db);
    }
    int midVert = rooms.getAncestor(a, dHalf);
    int aPredec = rooms.getAncestor(a, dHalf - 1);
    cout << rooms.subtreeSize(midVert) - rooms.subtreeSize(aPredec) << '\n';
  }
  return 0;
}
