#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  return x;
}
int n, m, a, b, t, dis;
int nume, to[200008], nxt[200008], head[100008];
inline void addedge(int x, int y) {
  ++nume;
  to[nume] = y;
  nxt[nume] = head[x];
  head[x] = nume;
}
int sz[100008], fa[100008], dep[100008], heavyson[100008], topfa[100008];
inline void dfs(int x) {
  sz[x] = 1;
  for (int i = head[x]; i; i = nxt[i]) {
    if (to[i] != fa[x]) {
      fa[to[i]] = x;
      dep[to[i]] = dep[x] + 1;
      dfs(to[i]);
      sz[x] += sz[to[i]];
      if (sz[to[i]] > sz[heavyson[x]]) {
        heavyson[x] = to[i];
      }
    }
  }
}
inline void dfs2(int x) {
  x == heavyson[fa[x]] ? topfa[x] = topfa[fa[x]] : topfa[x] = x;
  for (int i = head[x]; i; i = nxt[i]) {
    if (to[i] != fa[x]) dfs2(to[i]);
  }
}
int dfn[100008], num, id[100008];
inline void dfs3(int x) {
  dfn[x] = ++num;
  id[num] = x;
  if (heavyson[x]) dfs3(heavyson[x]);
  for (int i = head[x]; i; i = nxt[i]) {
    if (to[i] != heavyson[x] && to[i] != fa[x]) {
      dfs3(to[i]);
    }
  }
}
inline int lca(int x, int y) {
  while (topfa[x] != topfa[y]) {
    dep[topfa[x]] > dep[topfa[y]] ? x = fa[topfa[x]] : y = fa[topfa[y]];
  }
  return dep[x] < dep[y] ? x : y;
}
inline int solve(int x, int dis) {
  int pre;
  while (dfn[x] - dfn[topfa[x]] < dis) {
    dis -= dfn[x] - dfn[topfa[x]] + 1;
    pre = topfa[x];
    x = fa[topfa[x]];
  }
  if (dis == 0) {
    return sz[x] - sz[pre];
  }
  return sz[id[dfn[x] - dis]] - sz[id[dfn[x] - dis + 1]];
}
inline int solve2(int x, int y, int t) {
  int ans = 0;
  while (1) {
    if (topfa[x] == topfa[t]) {
      ans += sz[id[dfn[t] + 1]];
      break;
    }
    x = topfa[x];
    if (fa[x] == t) {
      ans += sz[x];
      break;
    }
    x = fa[x];
  }
  while (1) {
    if (topfa[y] == topfa[t]) {
      ans += sz[id[dfn[t] + 1]];
      break;
    }
    y = topfa[y];
    if (fa[y] == t) {
      ans += sz[y];
      break;
    }
    y = fa[y];
  }
  return ans;
}
int main() {
  n = read();
  for (int i = 1; i < n; ++i) {
    a = read();
    b = read();
    addedge(a, b);
    addedge(b, a);
  }
  dfs(1);
  dfs2(1);
  dfs3(1);
  m = read();
  while (m--) {
    a = read();
    b = read();
    if (a == b) {
      printf("%d\n", n);
      continue;
    }
    t = lca(a, b);
    dis = dep[a] + dep[b] - 2 * dep[t];
    if (dis % 2) {
      puts("0");
      continue;
    }
    if (dep[a] - dep[t] == dep[b] - dep[t]) {
      printf("%d\n", n - solve2(a, b, t));
      continue;
    }
    if (dep[a] < dep[b]) swap(a, b);
    dis /= 2;
    printf("%d\n", solve(a, dis));
  }
  return 0;
}
