#include <bits/stdc++.h>
using namespace std;
int level[100020];
int par[100020][25];
int cnt[100020];
vector<int> graph[100020];
void dfs(int v, int p = -1) {
  ++cnt[v];
  par[v][0] = p;
  for (int i = 1; i < 25; ++i) {
    par[v][i] = par[par[v][i - 1]][i - 1];
  }
  for (auto &w : graph[v]) {
    if (w == p) continue;
    level[w] = level[v] + 1;
    dfs(w, v);
    cnt[v] += cnt[w];
  }
}
int get_up(int v, int d) {
  for (int i = 25 - 1; i >= 0; --i) {
    if (d & (1 << i)) {
      v = par[v][i];
    }
  }
  return v;
}
int find_lca(int a, int b) {
  int dif = level[a] - level[b];
  a = get_up(a, dif);
  if (a == b) return a;
  for (int i = 25 - 1; i >= 0; --i) {
    if (par[a][i] != par[b][i]) {
      a = par[a][i];
      b = par[b][i];
    }
  }
  return par[a][0];
}
int solve(int a, int b) {
  if (level[a] < level[b]) {
    return solve(b, a);
  }
  int lca = find_lca(a, b);
  cerr << "lca: " << lca << endl;
  int path = level[a] + level[b] - 2 * level[lca];
  if (path % 2 != 0) {
    return 0;
  }
  int ans;
  int pa = get_up(a, (path / 2) - 1);
  if (level[a] == level[b]) {
    int pb = get_up(b, (path / 2) - 1);
    ans = cnt[1] - cnt[pa] - cnt[pb];
  } else {
    ans = cnt[par[pa][0]] - cnt[pa];
  }
  return ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i + 1 < n; ++i) {
    int a, b;
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  dfs(1);
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      cout << n << endl;
    } else {
      cout << solve(a, b) << endl;
    }
  }
  return 0;
}
