#include <bits/stdc++.h>
using namespace std;
struct node {
  int v, nxt;
} e[100010 << 2];
int head[100010], cnt;
int dep[100010];
int fa[100010][25];
int size[100010];
int n, m;
void add(int u, int v) {
  e[++cnt].v = v;
  e[cnt].nxt = head[u];
  head[u] = cnt;
}
void dfs(int u, int f) {
  size[u] = 1;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == f) continue;
    fa[v][0] = u;
    dep[v] = dep[u] + 1;
    dfs(v, u);
    size[u] += size[v];
  }
}
int getlca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int high = dep[x] - dep[y];
  for (int i = 24; i >= 0; i--) {
    int f = fa[x][i];
    if (dep[y] <= dep[f] && f) {
      x = f;
    }
  }
  if (x == y) return x;
  for (int i = 24; i >= 0; i--) {
    int fx = fa[x][i];
    int fy = fa[y][i];
    if (fx != fy && fx && fy) {
      x = fx;
      y = fy;
    }
  }
  return fa[x][0];
}
int solve1(int x, int dis) {
  int id = 0;
  while (dis) {
    if (dis & 1) x = fa[x][id];
    id++;
    dis >>= 1;
  }
  return x;
}
void file() {
  freopen("running.in", "r", stdin);
  freopen("running.out", "w", stdout);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    add(u, v);
    add(v, u);
  }
  dep[1] = 0;
  dfs(1, 0);
  for (int j = 1; j < 25; j++) {
    for (int i = 1; i <= n; i++) {
      fa[i][j] = fa[fa[i][j - 1]][j - 1];
    }
  }
  scanf("%d", &m);
  for (int tt = 1; tt <= m; tt++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int sum = 0;
    if (x == y) {
      printf("%d\n", n);
      continue;
    }
    if (dep[x] < dep[y]) swap(x, y);
    int lca = getlca(x, y);
    int dis = dep[x] + dep[y] - dep[lca] * 2;
    if (dis & 1) {
      printf("0\n");
      continue;
    }
    dis >>= 1;
    int posdep = dep[x] - dis;
    if (dep[x] == dep[y]) {
      int x1 = solve1(x, dis - 1);
      int y1 = solve1(y, dis - 1);
      sum = n - size[x1] - size[y1];
    } else {
      int x1 = solve1(x, dis);
      int y1 = solve1(x, dis - 1);
      sum = size[x1] - size[y1];
    }
    printf("%d\n", sum);
  }
  return 0;
}
