#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 5, LOG = 17;
int n, q, fst[MAXN], nxt[MAXN << 2], to[MAXN << 2], h[MAXN], p[MAXN][LOG],
    child[MAXN];
int Edges = 0;
template <class T>
void rd(T &a) {
  char ch = getchar();
  bool ng = 0;
  a = 0;
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') ng = 1;
  for (; ch >= '0' && ch <= '9'; ch = getchar())
    a = (a << 1) + (a << 3) + (ch ^ '0');
  if (ng) a = ~a + 1;
}
template <class T>
inline void wrt(T a) {
  if (a < 0) {
    putchar('-');
    wrt(~a + 1);
  } else {
    if (a > 9) wrt(a / 10);
    putchar(a % 10 ^ '0');
  }
}
inline void ins(int u, int v) {
  nxt[++Edges] = fst[u], fst[u] = Edges, to[Edges] = v;
}
inline void dfs(int u) {
  child[u] = 1;
  for (int i = 1; i < LOG; ++i) p[u][i] = p[p[u][i - 1]][i - 1];
  for (int i = fst[u]; i; i = nxt[i]) {
    int v = to[i];
    if (v == p[u][0]) continue;
    p[v][0] = u, h[v] = h[u] + 1, dfs(v), child[u] += child[v];
  }
}
inline int kth_par(int u, int k) {
  for (int i = 0; i < LOG; ++i)
    if (k & (1 << i)) u = p[u][i];
  return u;
}
inline int lca(int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  u = kth_par(u, h[u] - h[v]);
  for (int i = LOG - 1; ~i; --i)
    if (p[u][i] != p[v][i]) u = p[u][i], v = p[v][i];
  return u == v ? u : p[v][0];
}
inline int query(int u, int v) {
  if (u == v) return n;
  int anc = lca(u, v), dis = h[u] + h[v] - (h[anc] << 1);
  if (dis & 1) return 0;
  if (h[u] == h[v])
    return n - child[kth_par(u, h[u] - h[anc] - 1)] -
           child[kth_par(v, h[v] - h[anc] - 1)];
  if (h[u] < h[v]) swap(u, v);
  int x = kth_par(u, (dis >> 1) - 1);
  return child[p[x][0]] - child[x];
}
int main() {
  rd(n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    rd(u), rd(v);
    ins(u, v), ins(v, u);
  }
  dfs(1), rd(q);
  while (q--) {
    int u, v;
    rd(u), rd(v);
    wrt(query(u, v)), puts("");
  }
  return 0;
}
