#include <bits/stdc++.h>
using namespace std;
inline void setIO(string a) {}
struct e {
  int u, v, pre;
  e(int u = 0, int v = 0, int p = 0) : u(u), v(v), pre(p) {}
} edge[200005];
int dex, adj[100005];
int fa[100005][25], dep[100005], n, sz[100005];
inline void dfs(int x) {
  sz[x] = 1;
  for (int i = adj[x]; i; i = edge[i].pre) {
    int v = edge[i].v;
    if (v == fa[x][0]) continue;
    fa[v][0] = x;
    dep[v] = dep[x] + 1;
    for (int i = 1; i <= 20; i++) fa[v][i] = fa[fa[v][i - 1]][i - 1];
    dfs(v);
    sz[x] += sz[v];
  }
}
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];
}
int anc(int x, int y) {
  for (int i = 20; i >= 0; i--)
    if ((1 << i) <= y) y -= 1 << i, x = fa[x][i];
  return x;
}
int m;
int main() {
  scanf("%d", &n);
  dep[1] = 1;
  for (int i = 1; i <= n - 1; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    edge[++dex] = e(x, y, adj[x]);
    adj[x] = dex;
    edge[++dex] = e(y, x, adj[y]);
    adj[y] = dex;
  }
  dfs(1);
  scanf("%d", &m);
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x == y) {
      printf("%d\n", n);
      continue;
    }
    int p = lca(x, y), Ans = 0;
    if (dep[x] - dep[p] == dep[y] - dep[p]) {
      int A = anc(x, dep[x] - dep[p] - 1), B = anc(y, dep[y] - dep[p] - 1);
      Ans += sz[p] - sz[A] - sz[B];
      Ans += n - sz[p];
      printf("%d\n", Ans);
    } else {
      if (dep[x] - dep[p] < dep[y] - dep[p]) swap(x, y);
      if ((dep[x] + dep[y] - 2 * dep[p]) & 1) {
        printf("%d\n", 0);
        continue;
      } else {
        int A = anc(x, (dep[x] + dep[y] - 2 * dep[p]) >> 1);
        int B = anc(x, dep[x] - dep[A] - 1);
        printf("%d\n", sz[A] - sz[B]);
      }
    }
  }
  return 0;
}
