#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int n, m, cnt;
int head[maxn], fa[maxn][20], h[maxn], son[maxn];
bool vis[maxn];
struct Edge {
  int to, next;
} edge[maxn << 1];
inline void add(int u, int v) {
  edge[cnt].to = v;
  edge[cnt].next = head[u];
  head[u] = cnt++;
}
int dfs(int u) {
  vis[u] = 1;
  for (int i = head[u]; ~i; i = edge[i].next) {
    int v = edge[i].to;
    if (!vis[v]) {
      fa[v][0] = u;
      h[v] = h[u] + 1;
      son[u] += dfs(v);
    }
  }
  return son[u] = son[u] + 1;
}
inline void Pre() {
  dfs(1);
  for (int j = 1; j <= 19; j++)
    for (int i = 1; i <= n; i++) fa[i][j] = fa[fa[i][j - 1]][j - 1];
}
inline int lca(int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  int k = h[u] - h[v];
  for (int i = 19, j = 1 << 19; i >= 0; i--, j >>= 1)
    if (j <= k) u = fa[u][i], k -= j;
  if (u == v) return u;
  for (int i = 19; i >= 0; i--)
    if (fa[u][i] != fa[v][i]) u = fa[u][i], v = fa[v][i];
  return fa[u][0];
}
inline int far(int u, int v) {
  int k = h[u] - h[v] - 1;
  for (int i = 19, j = 1 << 19; i >= 0; i--, j >>= 1)
    if (j <= k) u = fa[u][i], k -= j;
  return u;
}
inline int fak(int u, int k) {
  for (int i = 19, j = 1 << 19; i >= 0; i--, j >>= 1)
    if (j <= k) u = fa[u][i], k -= j;
  return u;
}
inline int D(int u, int v, int p) { return h[u] + h[v] - (h[p] << 1); }
inline int solve(int u, int v) {
  int p = lca(u, v);
  if (D(u, v, p) & 1) return 0;
  if (u == v) return n;
  if (h[u] == h[v]) return n - son[far(u, p)] - son[far(v, p)];
  if (h[u] < h[v]) swap(u, v);
  int mid = fak(u, D(u, v, p) >> 1);
  return son[mid] - son[far(u, mid)];
}
inline int read() {
  int ans = 0;
  char c;
  while (!isdigit(c = getchar()))
    ;
  while (isdigit(c)) ans = (ans << 1) + (ans << 3) + (c ^ 48), c = getchar();
  return ans;
}
void print(int x) {
  if (x >= 10) print(x / 10);
  putchar(x % 10 + '0');
}
int main() {
  memset(head, -1, sizeof(head));
  n = read();
  int u, v;
  for (int i = 1; i < n; i++) {
    u = read(), v = read();
    add(u, v);
    add(v, u);
  }
  Pre();
  m = read();
  while (m--) {
    u = read(), v = read();
    print(solve(u, v));
    putchar('\n');
  }
  return 0;
}
