#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 11;
int depth[maxn], up[maxn][25], head[maxn], son[maxn];
bool vis[maxn];
int n, m, k, top, a, b, c, ans;
struct edge {
  int to, next;
} e[maxn << 1];
void ini() {
  memset(depth, 0, sizeof depth);
  memset(up, 0, sizeof up);
  memset(head, 0, sizeof head);
  memset(vis, 0, sizeof vis);
  memset(son, 0, sizeof son);
  top = 0;
}
void addedge(int x, int y) {
  e[++top] = (edge){y, head[x]};
  head[x] = top;
}
int dfs(int x) {
  if (vis[x]) return son[x];
  vis[x] = 1;
  for (int i = head[x]; i; i = e[i].next) {
    int v = e[i].to;
    if (vis[v]) continue;
    son[x]++;
    if (!vis[v] && !depth[v]) {
      depth[v] = depth[x] + 1;
      up[v][0] = x;
      son[x] += dfs(v);
    }
  }
  return son[x];
}
void pre() {
  for (int j = 1; j <= 20; j++)
    for (int i = 1; i <= n; i++) up[i][j] = up[up[i][j - 1]][j - 1];
}
int lca(int x, int y) {
  if (depth[x] < depth[y]) x ^= y, y ^= x, x ^= y;
  int c = depth[x] - depth[y];
  for (int i = 0; i < 20; i++) {
    if (c & (1 << i)) x = up[x][i];
  }
  if (x == y) return x;
  for (int i = 20; i >= 0; i--) {
    if (up[x][i] != up[y][i]) {
      x = up[x][i];
      y = up[y][i];
    }
  }
  return up[x][0];
}
void Find(int st, int len, int& las, int& fa) {
  len--;
  if (len == 0) {
    las = st, fa = up[st][0];
    return;
  }
  for (int i = 0; i < 20; i++)
    if (len & (1 << i)) st = up[st][i];
  las = st, fa = up[st][0];
}
int main() {
  ini();
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    addedge(a, b);
    addedge(b, a);
  }
  scanf("%d", &m);
  dfs(1);
  pre();
  while (m--) {
    scanf("%d%d", &a, &b);
    if ((depth[a] + depth[b]) % 2) {
      puts("0");
      continue;
    }
    if (a == b) {
      printf("%d\n", n);
      continue;
    }
    int ance = lca(a, b);
    int las1 = 0, las2 = 0, fa1 = 0, fa2 = 0;
    if (depth[a] > depth[b])
      Find(a, (depth[a] + depth[b] - 2 * depth[ance]) >> 1, las1, fa1),
          ans = son[fa1] - son[las1];
    else if (depth[a] < depth[b])
      Find(b, (depth[a] + depth[b] - 2 * depth[ance]) >> 1, las2, fa2),
          ans = son[fa2] - son[las2];
    else {
      Find(a, abs(depth[ance] - depth[a]), las1, fa1),
          Find(b, abs(depth[ance] - depth[b]), las2, fa2),
          ans = n - son[las1] - son[las2] - 2;
    }
    printf("%d\n", ans);
  }
}
