#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, Q, dep[N], par[N][20], sz[N];
vector<int> g[N];
void dfs(int u, int f, int d) {
  par[u][0] = f, dep[u] = d, sz[u] = 1;
  for (int i = (int)(1); i <= (int)(18); ++i)
    par[u][i] = par[par[u][i - 1]][i - 1];
  for (int v : g[u])
    if (v != f) dfs(v, u, d + 1), sz[u] += sz[v];
}
int glca(int u, int v) {
  int &c = dep[u] >= dep[v] ? u : v, d = abs(dep[u] - dep[v]);
  for (int i = (int)(0); i <= (int)(18); ++i)
    if (d >> i & 1) c = par[c][i];
  if (u == v) return u;
  for (int i = (int)(18); i >= (int)(0); --i)
    if (par[u][i] != par[v][i]) u = par[u][i], v = par[v][i];
  return par[u][0];
}
int gp(int u, int d) {
  for (int i = (int)(18); i >= (int)(0); --i)
    if (d >> i & 1) u = par[u][i];
  return u;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (int)(n - 1); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u, --v;
    g[u].push_back(v), g[v].push_back(u);
  }
  srand(time(0));
  int rt = rand() % n;
  dfs(rt, rt, 0);
  scanf("%d", &Q);
  while (Q--) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u, --v;
    if (u == v) {
      printf("%d\n", n);
      continue;
    }
    if (dep[u] < dep[v]) swap(u, v);
    int l = glca(u, v);
    int d = dep[u] + dep[v] - 2 * dep[l];
    if (d & 1) {
      puts("0");
      continue;
    }
    int d1 = dep[u] - dep[l], d2 = dep[v] - dep[l], res;
    if (d1 == d2) {
      int pu = gp(u, d1 - 1), pv = gp(v, d2 - 1);
      res = n - sz[pu] - sz[pv];
    } else {
      d /= 2;
      int p1 = gp(u, d), p2 = gp(u, d - 1);
      res = sz[p1] - sz[p2];
    }
    printf("%d\n", res);
  }
  return 0;
}
