#include <bits/stdc++.h>
using namespace std;
const int maxn = 112345;
vector<int> G[maxn];
int n, m, dep[maxn], st[maxn][18], bit[18], sz[maxn];
void dfs(int u, int par) {
  dep[u] = dep[par] + 1;
  st[u][0] = par;
  for (int(i) = (1); (i) <= (17); (i)++) st[u][i] = st[st[u][i - 1]][i - 1];
  sz[u] = 1;
  for (int v : G[u])
    if (v != par) {
      dfs(v, u);
      sz[u] += sz[v];
    }
}
int main() {
  for (int(i) = (0); (i) <= ((18) - 1); (i)++) bit[i] = 1 << i;
  scanf("%d", &n);
  for (int(i) = (0); (i) <= ((n - 1) - 1); (i)++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }
  dfs(1, 0);
  scanf("%d", &m);
  while (m--) {
    int u, v;
    scanf("%d%d", &u, &v);
    if ((dep[u] ^ dep[v]) & 1) {
      puts("0");
      continue;
    }
    if (u == v) {
      printf("%d\n", n);
      continue;
    }
    if (dep[u] > dep[v]) swap(u, v);
    int x = u, y = v;
    for (int(i) = (17); (i) >= (0); (i)--)
      if (dep[y] - dep[x] >= bit[i]) y = st[y][i];
    for (int(i) = (17); (i) >= (0); (i)--)
      if (st[x][i] != st[y][i]) x = st[x][i], y = st[y][i];
    int a = x == y ? x : st[x][0], need = dep[u] + dep[v] - 2 * dep[a] >> 1;
    need--;
    if (dep[u] == dep[v]) {
      x = u, y = v;
      for (int(i) = (17); (i) >= (0); (i)--)
        if (bit[i] <= need) y = st[y][i], x = st[x][i], need -= bit[i];
      printf("%d\n", n - sz[x] - sz[y]);
    } else {
      y = v;
      for (int(i) = (17); (i) >= (0); (i)--)
        if (bit[i] <= need) y = st[y][i], need -= bit[i];
      printf("%d\n", sz[st[y][0]] - sz[y]);
    }
  }
}
