#include <bits/stdc++.h>
using namespace std;
int n, t, head[100007], d[100007], num, f[100007][22], size[100007];
inline int qread() {
  char c = getchar();
  int num = 0, f = 1;
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) num = num * 10 + c - '0';
  return num * f;
}
struct node {
  int v, nxt;
} e[100007 << 1];
inline void ct(int u, int v) {
  e[++num].v = v;
  e[num].nxt = head[u];
  head[u] = num;
}
void dfs(int u, int fa) {
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v != fa) {
      f[v][0] = u;
      d[v] = d[u] + 1;
      dfs(v, u);
      size[u] += size[v];
    }
  }
}
inline int lca(int a, int b) {
  if (d[a] > d[b]) swap(a, b);
  for (int i = 20; i >= 0; --i)
    if (d[a] <= d[b] - (1 << i)) b = f[b][i];
  if (a == b) return a;
  for (int i = 20; i >= 0; --i)
    if (f[a][i] != f[b][i]) a = f[a][i], b = f[b][i];
  return f[a][0];
}
int main() {
  n = qread();
  for (int i = 1, u, v; i < n; ++i) {
    u = qread(), v = qread();
    ct(u, v);
    ct(v, u);
  }
  for (int i = 1; i <= n; ++i) size[i] = 1;
  dfs(1, 0);
  for (int j = 1; j <= 20; ++j)
    for (int i = 1; i <= n; ++i) f[i][j] = f[f[i][j - 1]][j - 1];
  t = qread();
  for (int i = 1, u, v; i <= t; ++i) {
    u = qread(), v = qread();
    if (d[u] < d[v]) swap(u, v);
    if ((d[u] + d[v] - 2 * (d[lca(u, v)])) & 1) {
      printf("0\n");
      continue;
    }
    int lc = lca(u, v), x = u;
    int p = (d[u] + d[v] - 2 * d[lc]) / 2 - 1;
    for (int i = 20; i >= 0; --i)
      if (p & (1 << i)) u = f[u][i];
    if (d[x] == d[v]) {
      p = d[v] - d[lc] - 1;
      for (int i = 20; i >= 0; --i)
        if (p & (1 << i)) v = f[v][i];
      printf("%d\n", n - size[u] - size[v]);
    } else
      printf("%d\n", size[f[u][0]] - size[u]);
  }
  return 0;
}
