#include <bits/stdc++.h>
using namespace std;
const int MAXP = 20, maxn = 1e6;
vector<int> adj[maxn];
int par[maxn][MAXP], size[maxn], D[maxn], n, q, l;
bool mark[maxn];
int parent(int x, int d) {
  if (d == 0) return x;
  for (int i = 0; i < MAXP; i++)
    if ((d >> i) & 1) x = par[x][i];
  return x;
}
int lca(int x, int y) {
  if (D[x] < D[y]) swap(x, y);
  x = parent(x, D[x] - D[y]);
  if (x == y) return x;
  for (int i = MAXP - 1; i >= 0; i--) {
    if (par[x][i] != par[y][i]) {
      x = par[x][i];
      y = par[y][i];
    }
  }
  return par[x][0];
}
void dfs(int x) {
  size[x] = 1;
  mark[x] = true;
  for (int i = 0; i < adj[x].size(); i++) {
    int v = adj[x][i];
    if (!mark[v]) {
      par[v][0] = x;
      D[v] = D[x] + 1;
      for (int j = 1; j < MAXP; j++) par[v][j] = par[par[v][j - 1]][j - 1];
      dfs(v);
      size[x] += size[v];
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1, v, u; i <= n - 1; i++) {
    cin >> v >> u;
    adj[v].push_back(u);
    adj[u].push_back(v);
  }
  cin >> q;
  dfs(1);
  for (int i = 1, x, y; i <= q; i++) {
    cin >> x >> y;
    l = lca(x, y);
    if (x == y)
      cout << n << '\n';
    else if ((D[x] - D[l] + D[y] - D[l]) % 2 == 1)
      cout << 0 << '\n';
    else if ((D[x] - D[l]) == (D[y] - D[l])) {
      int p1 = D[x] - D[l] - 1;
      int p2 = parent(y, p1);
      p1 = parent(x, p1);
      cout << n - size[p1] - size[p2] << '\n';
    } else {
      if (D[x] < D[y]) swap(x, y);
      int p1 = (D[x] - D[l] + D[y] - D[l]) / 2;
      int p2 = (D[x] - D[l] + D[y] - D[l]) / 2 - 1;
      p1 = parent(x, p1);
      p2 = parent(x, p2);
      cout << size[p1] - size[p2] << '\n';
    }
  }
}
