#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
vector<int> vc[N + 10];
int par[N + 10][30];
int h[N + 10], child[N + 10];
int n;
void DFS(int v, int pr = 0) {
  par[v][0] = pr;
  for (int i = 1; i < 20; i++) par[v][i] = par[par[v][i - 1]][i - 1];
  child[v] = 1;
  for (int i = 0; i < vc[v].size(); i++) {
    int u = vc[v][i];
    if (u != pr) h[u] = h[v] + 1, DFS(u, v), child[v] += child[u];
  }
  return;
}
int Par(int v, int he) {
  for (int i = 0; i < 20; i++)
    if (he & (1 << i)) v = par[v][i];
  return v;
}
int find_ans(int v, int u) {
  if (u == v) return n;
  if (h[u] < h[v]) swap(u, v);
  int dif = h[u] - h[v], v_ = v, u_ = Par(u, h[u] - h[v]);
  if (dif % 2) return 0;
  if (u_ == v)
    return child[Par(u, (h[u] - h[v]) / 2)] -
           child[Par(u, (h[u] - h[v]) / 2 - 1)];
  for (int i = 19; i >= 0; i--)
    if (par[v_][i] != par[u_][i]) v_ = par[v_][i], u_ = par[u_][i];
  int Pr = par[v_][0];
  if (!dif)
    return n - child[Par(u, h[u] - h[Pr] - 1)] -
           child[Par(v, h[v] - h[Pr] - 1)];
  return child[Par(u, h[u] - h[Pr] - dif / 2)] -
         child[Par(u, h[u] - h[Pr] - dif / 2 - 1)];
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    vc[x].push_back(y), vc[y].push_back(x);
  }
  DFS(1);
  int q;
  cin >> q;
  while (q--) {
    int x, y;
    cin >> x >> y;
    cout << find_ans(x, y) << endl;
  }
  return 0;
}
