#include <bits/stdc++.h>
using namespace std;
const int N = 1E5 + 10;
const int K = 20;
vector<int> adj[N];
int n;
int par[N], h[N], child[N];
int P[N][K];
void Read_Input() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) adj[i].push_back(0);
}
void DFS(int u) {
  child[u] = 1;
  for (int i = 0; int v = adj[u][i]; i++)
    if (par[v] == 0) {
      par[v] = u;
      h[v] = h[u] + 1;
      DFS(v);
      child[u] += child[v];
    }
}
void Build_LCA() {
  h[1] = 1;
  par[1] = 1;
  DFS(1);
  for (int i = 1; i <= n; i++) P[i][0] = par[i];
  for (int j = 1; 1 << j <= n; j++)
    for (int i = 1; i <= n; i++) P[i][j] = P[P[i][j - 1]][j - 1];
}
int LCA(int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  int k = trunc(log(h[u]) / log(2));
  for (int i = k; i >= 0; i--)
    if (h[P[u][i]] >= h[v]) u = P[u][i];
  for (int i = k; i >= 0; i--)
    if (h[P[v][i]] >= h[u]) v = P[v][i];
  if (u == v) return u;
  for (int i = k; i >= 0; i--)
    if (P[u][i] != P[v][i]) u = P[u][i], v = P[v][i];
  return par[u];
}
int Find(int u, int p) {
  if (p == 0) return u;
  int k = trunc(log(h[u] + p) / log(2));
  for (int i = 0; i <= k; i++)
    if (p & (1 << i)) u = P[u][i];
  return u;
}
int Dist(int x, int y) { return h[x] + h[y] - 2 * h[LCA(x, y)]; }
int Cal(int x, int y) {
  if (h[x] < h[y]) swap(x, y);
  if (Dist(x, y) & 1) return 0;
  if (x == y) return child[1];
  int p = LCA(x, y);
  if (Dist(x, p) == Dist(p, y)) {
    x = Find(x, Dist(x, p) - 1);
    y = Find(y, Dist(y, p) - 1);
    return child[1] - child[x] - child[y];
  }
  int l = Find(x, Dist(x, y) / 2 - 1);
  int r = Find(x, Dist(x, y) / 2);
  return child[r] - child[l];
}
void Solve() {
  int q;
  scanf("%d", &q);
  while (q--) {
    int u, v;
    scanf("%d%d", &u, &v);
    printf("%d\n", Cal(u, v));
  }
}
int main() {
  Read_Input();
  Build_LCA();
  Solve();
  return 0;
}
