#include <bits/stdc++.h>
using namespace std;
struct node {
  int v, nxt;
} e[100005 << 1];
int tot;
int head[100005];
inline void add(int a, int b) {
  ++tot;
  e[tot].v = b;
  e[tot].nxt = head[a];
  head[a] = tot;
}
int n, m;
int siz[100005];
int dep[100005];
int p[100005][30];
inline void dfs(int x, int fa) {
  siz[x] = 1;
  dep[x] = dep[fa] + 1;
  p[x][0] = fa;
  for (int i = 1; i <= 20; i++) p[x][i] = p[p[x][i - 1]][i - 1];
  for (int i = head[x]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    dfs(v, x);
    siz[x] += siz[v];
  }
}
inline int lca(int a, int b) {
  if (dep[a] > dep[b]) swap(a, b);
  for (int i = 20; i >= 0; i--) {
    if (dep[b] - dep[a] >= (1 << i)) b = p[b][i];
  }
  if (a == b) return a;
  for (int i = 20; i >= 0; i--) {
    if (p[a][i] == p[b][i]) continue;
    a = p[a][i];
    b = p[b][i];
  }
  return p[a][0];
}
inline int juli(int a, int b) { return dep[a] + dep[b] - 2 * dep[lca(a, b)]; }
inline int jump(int x, int step, int flag) {
  int de = dep[x] - step;
  for (int i = 20; i >= 0; i--) {
    if (dep[x] - de > (1 << i)) x = p[x][i];
  }
  if (flag == 1) return siz[p[x][0]] - siz[x];
  if (flag == 2) return siz[x];
  if (flag == 3) return siz[p[x][0]] - siz[x];
  return 0;
}
inline int solve(int a, int b) {
  if (a == b) return n;
  int zuxian = lca(a, b);
  int tiao = juli(a, b);
  if (tiao & 1) return 0;
  if (zuxian == a || zuxian == b) {
    if (dep[a] > dep[b]) swap(a, b);
    return jump(b, tiao / 2, 1);
  } else if (dep[a] == dep[b]) {
    return n - jump(a, tiao / 2, 2) - jump(b, tiao / 2, 2);
  } else {
    if (dep[a] > dep[b]) swap(a, b);
    return jump(b, tiao / 2, 3);
  }
}
int a, b;
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
    add(a, b);
    add(b, a);
  }
  dfs(1, 0);
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d", &a, &b);
    printf("%d\n", solve(a, b));
  }
}
