#include <bits/stdc++.h>
using namespace std;
struct data {
  int to, next;
} e[100010 << 1];
int fa[100010][21];
int head[100010], dep[100010], sz[100010];
int n, m, cnt;
inline int read() {
  char c;
  int fe = 0, f = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') f = -1;
  fe = c - '0';
  while (isdigit(c = getchar())) fe = fe * 10 + c - '0';
  return fe * f;
}
inline void insert(int x, int y) {
  e[++cnt].next = head[x];
  head[x] = cnt;
  e[cnt].to = y;
}
void dfs(int x) {
  dep[x] = dep[fa[x][0]] + 1;
  sz[x] = 1;
  for (int i = 1; i <= 20; ++i) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  for (int i = head[x]; i; i = e[i].next) {
    int y = e[i].to;
    if (y == fa[x][0]) continue;
    fa[y][0] = x;
    dfs(y);
    sz[x] += sz[y];
  }
}
inline int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 20; i >= 0; --i)
    if (dep[fa[x][i]] >= dep[y]) x = fa[x][i];
  if (x == y) return x;
  for (int i = 20; i >= 0; --i)
    if (fa[x][i] != fa[y][i]) {
      x = fa[x][i];
      y = fa[y][i];
    }
  return fa[x][0];
}
inline int find(int x, int dis) {
  for (int i = 20; i >= 0; i--)
    if (dep[x] - dep[fa[x][i]] <= dis)
      dis = dis - dep[x] + dep[fa[x][i]], x = fa[x][i];
  return x;
}
int main() {
  n = read();
  for (int i = 1; i < n; ++i) {
    int x = read(), y = read();
    insert(x, y);
    insert(y, x);
  }
  dfs(1);
  m = read();
  for (int i = 1; i <= m; ++i) {
    int x = read(), y = read(), z = lca(x, y), ans = 0,
        dis = dep[x] + dep[y] - (dep[z] << 1);
    if (dep[x] < dep[y]) swap(x, y);
    if (x == y)
      ans = n;
    else if (dis & 1)
      ans = 0;
    else if (dep[x] == dep[y]) {
      int p1 = find(x, (dep[x] - dep[z] - 1)),
          p2 = find(y, (dep[y] - dep[z] - 1));
      ans = n - sz[p1] - sz[p2];
    } else {
      int p1 = find(x, dis >> 1), p2 = find(x, (dis >> 1) - 1);
      ans = sz[p1] - sz[p2];
    }
    printf("%d\n", ans);
  }
  return 0;
}
