#include <bits/stdc++.h>
using namespace std;
template <typename lx>
inline void read(lx &x) {
  x = 0;
  int f = 1;
  char c = getchar();
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar())
    x = (x << 1) + (x << 3) + (c ^ '0');
  x *= f;
  return;
}
template <typename lx>
inline void print(lx x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar(x % 10 + '0');
  return;
}
const int maxn = 1e5 + 5;
int a, b;
int n, m, tot, lit;
int head[maxn], dep[maxn], lg[maxn], s[maxn];
int f[maxn][20];
struct edge {
  int nxt, v;
} e[maxn << 1];
inline void add(int u, int v) {
  ++tot;
  e[tot].v = v;
  e[tot].nxt = head[u];
  head[u] = tot;
  return;
}
inline int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  while (dep[x] > dep[y]) x = f[x][lg[dep[x] - dep[y]]];
  if (x == y) return y;
  for (register int i = lit; i >= 0; i--)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
void dfs(int x, int fa) {
  dep[x] = dep[fa] + 1;
  f[x][0] = fa;
  s[x] = 1;
  for (register int i = 1; (1 << i) <= dep[x]; i++)
    f[x][i] = f[f[x][i - 1]][i - 1];
  for (register int i = head[x]; i; i = e[i].nxt) {
    int v = e[i].v;
    if (v == fa) continue;
    dfs(v, x);
    s[x] += s[v];
  }
  return;
}
inline void init() {
  read(n);
  for (register int i = 2; i <= n; i++) lg[i] = lg[i >> 1] + 1;
  lit = lg[n];
  for (register int i = 1; i < n; i++) read(a), read(b), add(a, b), add(b, a);
  dfs(1, 0);
  return;
}
inline int tree_up(int ori, int k) {
  for (register int i = lg[k] + 1; i >= 0; i--)
    if ((1 << i) & k) ori = f[ori][i];
  return ori;
}
inline int solve(int x, int y) {
  int cnt = 0;
  if (x == y) return n;
  int Lca = lca(x, y);
  int low_n = dep[x] <= dep[y] ? y : x;
  int judge = dep[x] + dep[y] - dep[Lca] * 2;
  if (judge & 1)
    cnt = 0;
  else {
    int mid = judge >> 1;
    int up_n = tree_up(low_n, mid);
    if (dep[x] > dep[y]) {
      int x_up = tree_up(x, mid - 1);
      cnt = s[up_n] - s[x_up];
    } else if (dep[y] > dep[x]) {
      int y_up = tree_up(y, mid - 1);
      cnt = s[up_n] - s[y_up];
    } else {
      int x_up = tree_up(x, mid - 1), y_up = tree_up(y, mid - 1);
      cnt = n - s[x_up] - s[y_up];
    }
  }
  return cnt;
}
int main() {
  init();
  read(m);
  for (register int i = 0; i < m; i++) {
    read(a), read(b);
    printf("%d\n", solve(a, b));
  }
  return 0;
}
