#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
vector<int> edge[MAX];
int level[MAX];
int subtree[MAX];
int dp[MAX][20];
int dfs(int a, int prev) {
  level[a] = level[prev] + 1;
  dp[a][0] = prev;
  for (int j = 1; j < 20; j++) {
    dp[a][j] = dp[dp[a][j - 1]][j - 1];
  }
  int cnt = 1;
  for (auto e : edge[a]) {
    if (e == prev) {
      continue;
    }
    cnt += dfs(e, a);
  }
  subtree[a] = cnt;
  return cnt;
}
int moveNode(int a, int dist) {
  for (int j = 0; j < 20; j++) {
    if (dist & (1 << j)) {
      a = dp[a][j];
    }
  }
  return a;
}
int lca(int a, int b) {
  if (level[a] < level[b]) {
    swap(a, b);
  }
  int dist = level[a] - level[b];
  a = moveNode(a, dist);
  if (a == b) {
    return a;
  }
  for (int j = 19; j >= 0; j--) {
    if (dp[a][j] == dp[b][j]) {
      continue;
    }
    a = dp[a][j];
    b = dp[b][j];
  }
  return dp[a][0];
}
int main() {
  int n, q, a, b, c, node1, node2, node3;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  dfs(1, 1);
  subtree[1] = n;
  cin >> q;
  while (q--) {
    cin >> a >> b;
    if (level[a] < level[b]) {
      swap(a, b);
    }
    int diff = level[a] - level[b];
    c = lca(a, b);
    if (diff % 2) {
      cout << 0 << endl;
    } else if (a == b) {
      cout << n << endl;
    } else if (b == c) {
      node1 = moveNode(a, diff / 2);
      node2 = moveNode(a, diff / 2 - 1);
      cout << subtree[node1] - subtree[node2] << endl;
    } else if (diff == 0) {
      node1 = c;
      node2 = moveNode(a, level[a] - level[c] - 1);
      node3 = moveNode(b, level[b] - level[c] - 1);
      cout << n - subtree[node2] - subtree[node3] << endl;
    } else {
      int x = (level[a] + level[b] - level[c] * 2) / 2;
      node1 = moveNode(a, x);
      node2 = moveNode(a, x - 1);
      cout << subtree[node1] - subtree[node2] << endl;
    }
  }
}
