#include <bits/stdc++.h>
using namespace std;
int fat[100005][20], lev[100005], chi[100005];
int n, m;
vector<int> p[100005];
int dfs(int x, int fa) {
  int i, e, y;
  fat[x][0] = fa;
  lev[x] = lev[fa] + 1;
  e = p[x].size();
  for (i = 0; i < e; i++) {
    y = p[x][i];
    if (y == fa) continue;
    chi[x] += dfs(y, x);
  }
  chi[x]++;
  return chi[x];
}
int lca(int x, int y) {
  int i;
  if (lev[x] > lev[y]) swap(x, y);
  for (i = 19; i >= 0; i--) {
    if (lev[fat[y][i]] >= lev[x]) y = fat[y][i];
  }
  for (i = 19; i >= 0; i--) {
    if (fat[x][i] != fat[y][i]) {
      x = fat[x][i];
      y = fat[y][i];
    }
  }
  return (x == y) ? x : fat[x][0];
}
void init(int n) {
  int i, j;
  dfs(1, 0);
  for (i = 1; i <= 19; i++) {
    for (j = 0; j <= n; j++) {
      fat[j][i] = fat[fat[j][i - 1]][i - 1];
    }
  }
}
int main() {
  int i;
  int u, v, ans, g, mid;
  scanf("%d", &n);
  for (i = 0; i < n - 1; i++) {
    scanf("%d%d", &u, &v);
    p[u].push_back(v);
    p[v].push_back(u);
  }
  init(n);
  scanf("%d", &m);
  while (m--) {
    ans = 0;
    scanf("%d%d", &u, &v);
    if (lev[u] < lev[v]) swap(u, v);
    g = lca(u, v);
    if ((lev[u] + lev[v] - 2 * lev[g]) % 2) {
      printf("0\n");
      continue;
    }
    if (u == v) {
      printf("%d\n", n);
      continue;
    }
    if (lev[u] == lev[v]) {
      for (i = 19; i >= 0; i--) {
        if (lev[fat[u][i]] > lev[g]) u = fat[u][i];
        if (lev[fat[v][i]] > lev[g]) v = fat[v][i];
      }
      ans = n - chi[u] - chi[v];
    } else {
      mid = lev[u] + lev[v] - 2 * lev[g];
      mid = lev[u] - mid / 2;
      v = u;
      for (i = 19; i >= 0; i--) {
        if (lev[fat[u][i]] >= mid) u = fat[u][i];
        if (lev[fat[v][i]] >= mid + 1) v = fat[v][i];
      }
      ans = chi[u] - chi[v];
    }
    printf("%d\n", ans);
  }
  return 0;
}
