#include <bits/stdc++.h>
using namespace std;
vector<int> G[500005];
struct LCA {
  int d[500005], fa[500005][22], lg[500005], siz[500005];
  void init(int n, int root) {
    for (int i = 1; i <= n; ++i) {
      lg[i] = lg[i - 1] + (1 << lg[i - 1] == i);
    }
    dfs(root, 0);
  }
  void dfs(int now, int father) {
    fa[now][0] = father;
    d[now] = d[father] + 1;
    siz[now] = 1;
    for (int i = 1; i <= lg[d[now]]; ++i) {
      fa[now][i] = fa[fa[now][i - 1]][i - 1];
    }
    for (auto x : G[now]) {
      if (x != father) {
        dfs(x, now);
        siz[now] += siz[x];
      }
    }
  }
  int lca(int x, int y) {
    if (d[x] < d[y]) swap(x, y);
    while (d[x] > d[y]) {
      x = fa[x][lg[d[x] - d[y]] - 1];
    }
    if (x == y) return x;
    for (int k = lg[d[x]] - 1; k >= 0; --k) {
      if (fa[x][k] != fa[y][k]) {
        x = fa[x][k], y = fa[y][k];
      }
    }
    return fa[x][0];
  }
  int dis(int a, int b) { return d[a] + d[b] - 2 * d[lca(a, b)]; }
  int getk(int f, int k) {
    for (int i = 20; i >= 0; i--) {
      if (k & (1 << i)) {
        f = fa[f][i];
      }
    }
    return f;
  }
} lca;
int main() {
  int n, m, x, y;
  scanf("%d", &n);
  for (int i = 2; i <= n; i++) {
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  lca.init(n, 1);
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d", &x, &y);
    int dis = lca.dis(x, y);
    if (x == y) {
      printf("%d\n", n);
      continue;
    }
    if (dis % 2) {
      printf("%d\n", 0);
    } else {
      dis /= 2;
      int f, ans = 0;
      if (lca.d[x] < lca.d[y]) {
        f = lca.getk(y, dis - 1);
        ans = lca.siz[lca.fa[f][0]] - lca.siz[f];
      } else if (lca.d[x] > lca.d[y]) {
        f = lca.getk(x, dis - 1);
        ans = lca.siz[lca.fa[f][0]] - lca.siz[f];
      } else {
        int fa = lca.getk(x, dis - 1);
        int fb = lca.getk(y, dis - 1);
        ans = n - lca.siz[fa] - lca.siz[fb];
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
