#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
const int Log = 25;
vector<int> graph[N];
int n, q, a, b, timer;
int level[N], subtree[N], anc[N][Log], preorder[N], postorder[N];
void dfs(int v, int par = 1, int lev = 0) {
  level[v] = lev;
  subtree[v] = 1;
  preorder[v] = timer++;
  anc[v][0] = par;
  for (int i = 1; i < Log; ++i) {
    anc[v][i] = anc[anc[v][i - 1]][i - 1];
  }
  for (auto u : graph[v]) {
    if (u != par) {
      dfs(u, v, lev + 1);
      subtree[v] += subtree[u];
    }
  }
  postorder[v] = timer++;
}
bool is_ancestor(int a, int b) {
  return preorder[a] <= preorder[b] && postorder[b] <= postorder[a];
}
int climb(int a, int b) {
  for (int i = Log - 1; i >= 0; i--) {
    if (!is_ancestor(anc[a][i], b)) {
      a = anc[a][i];
    }
  }
  return a;
}
int lca(int a, int b) {
  int result = -1;
  if (is_ancestor(a, b)) {
    result = a;
  } else if (is_ancestor(b, a)) {
    result = b;
  } else {
    result = anc[climb(a, b)][0];
  }
  return result;
}
int query(int a, int b) {
  int l = lca(a, b);
  int result = -1;
  if (a == b) {
    result = n;
  } else if (level[a] - level[l] == level[b] - level[l]) {
    a = climb(a, l);
    b = climb(b, l);
    result = n - subtree[a] - subtree[b];
  } else {
    if (level[a] < level[b]) {
      swap(a, b);
    }
    int u = a;
    int dist = level[a] + level[b] - 2 * level[l];
    if (dist & 1) {
      result = 0;
    } else {
      dist >>= 1;
      for (int i = Log - 1; i >= 0; i--) {
        if (level[a] - level[anc[u][i]] < dist) {
          u = anc[u][i];
        }
      }
      int mid = anc[u][0];
      result = subtree[mid] - subtree[u];
    }
  }
  return result;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  dfs(1);
  cin >> q;
  while (q--) {
    cin >> a >> b;
    cout << query(a, b) << '\n';
  }
  return 0;
}
