#include <bits/stdc++.h>
using namespace std;
inline int read() {
  char c = getchar();
  int num = 0;
  for (; !isdigit(c); c = getchar())
    ;
  for (; isdigit(c); c = getchar()) num = num * 10 + c - '0';
  return num;
}
const int N = 1e5 + 5;
int head[N], num_edge;
struct Edge {
  int v, nxt;
} edge[N << 1];
inline void add_edge(int u, int v) {
  edge[++num_edge].v = v;
  edge[num_edge].nxt = head[u];
  head[u] = num_edge;
}
int fa[N][17], dep[N], siz[N];
void dfs(int u) {
  for (int i = 1; i <= 16; ++i) {
    fa[u][i] = fa[fa[u][i - 1]][i - 1];
    if (fa[u][i] == 0) break;
  }
  siz[u] = 1;
  for (int i = head[u], v; i; i = edge[i].nxt) {
    v = edge[i].v;
    if (v == fa[u][0]) continue;
    fa[v][0] = u;
    dep[v] = dep[u] + 1;
    dfs(v);
    siz[u] += siz[v];
  }
}
int jump(int x, int t) {
  for (int i = 0; t > 0; ++i, t >>= 1)
    if (t & 1) x = fa[x][i];
  return x;
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int t = dep[x] - dep[y];
  x = jump(x, t);
  if (x == y) return x;
  for (int i = 16; ~i; --i)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
int main() {
  int n = read();
  for (int i = 1, a, b; i < n; ++i) {
    a = read(), b = read();
    add_edge(a, b), add_edge(b, a);
  }
  dep[1] = 1;
  dfs(1);
  int m = read();
  for (int i = 1, a, b, g, t; i <= m; ++i) {
    a = read(), b = read();
    g = lca(a, b);
    t = dep[a] + dep[b] - 2 * dep[g];
    if (a == b)
      cout << siz[1] << '\n';
    else if (dep[a] == dep[b]) {
      t >>= 1;
      a = jump(a, t - 1), b = jump(b, t - 1);
      cout << siz[1] - siz[a] - siz[b] << '\n';
    } else {
      if (t & 1)
        cout << 0 << '\n';
      else {
        t >>= 1;
        if (dep[a] < dep[b]) swap(a, b);
        a = jump(a, t - 1);
        cout << siz[fa[a][0]] - siz[a] << '\n';
      }
    }
  }
  return 0;
}
