#include <bits/stdc++.h>
using namespace std;
const int MX = (1 << 20);
int n, depth[MX], dp[30][MX], QN;
vector<int> v[MX];
vector<int> sol;
vector<pair<pair<int, int>, int> > Q[MX];
void dfs(int x, int p) {
  int omar = v[x].size(), nxt;
  dp[0][x] = p;
  for (int j = 0; j < omar; j++) {
    nxt = v[x][j];
    if (nxt == p) continue;
    depth[nxt] = depth[x] + 1;
    dfs(nxt, x);
  }
}
int Kth(int x, int D) {
  int node = x;
  for (int j = 0; j < 30; j++)
    if ((D & (1 << j))) node = dp[j][node];
  return node;
}
int LCA(int u, int v) {
  if (depth[u] > depth[v]) swap(u, v);
  v = Kth(v, depth[v] - depth[u]);
  if (u == v) return u;
  for (int j = 29; j >= 0; j--) {
    if (dp[j][u] != dp[j][v] && min(dp[j][u], dp[j][v]) != -1) {
      u = dp[j][u], v = dp[j][v];
    }
  }
  return dp[0][u];
}
int P[MX], sz[MX];
int find_(int x) {
  if (x != P[x]) P[x] = find_(P[x]);
  return P[x];
}
void merge_(int x, int y) {
  x = find_(x), y = find_(y);
  if (x == y) return;
  if (sz[x] < sz[y]) swap(x, y);
  P[y] = x;
  sz[x] += sz[y];
}
void DFS(int x, int p) {
  int omar = v[x].size(), nxt, nodesz = 1;
  for (int j = 0; j < omar; j++) {
    nxt = v[x][j];
    if (nxt == p) continue;
    DFS(nxt, x);
    nodesz += sz[find_(nxt)];
  }
  omar = Q[x].size();
  int U, V, idx;
  for (int j = 0; j < omar; j++) {
    idx = Q[x][j].second, U = Q[x][j].first.first, V = Q[x][j].first.second;
    if (LCA(U, x) == x)
      sol[idx] -= sz[find_(U)];
    else
      sol[idx] -= (n - nodesz);
    if (LCA(V, x) == x)
      sol[idx] -= sz[find_(V)];
    else
      sol[idx] -= (n - nodesz);
  }
  omar = v[x].size();
  for (int j = 0; j < omar; j++) {
    nxt = v[x][j];
    if (nxt == p) continue;
    merge_(x, nxt);
  }
}
int main() {
  memset(dp, -1, sizeof(dp));
  scanf("%d", &n);
  for (int j = 1; j <= n; j++) P[j] = j, sz[j] = 1;
  for (int j = 1; j < n; j++) {
    int a, b;
    scanf("%d %d", &a, &b);
    v[a].push_back(b);
    v[b].push_back(a);
  }
  depth[1] = 1;
  dfs(1, -1);
  for (int j = 1; j < 30; j++)
    for (int i = 1; i <= n; i++)
      if (dp[j - 1][i] != -1) dp[j][i] = dp[j - 1][dp[j - 1][i]];
  scanf("%d", &QN);
  sol.resize(QN);
  for (int pp = 0; pp < QN; pp++) {
    int u, v;
    scanf("%d %d", &u, &v);
    sol[pp] = n;
    if (u == v) continue;
    int lca = LCA(u, v), dis;
    dis = depth[u] + depth[v] - 2 * depth[lca];
    if (depth[v] > depth[u]) swap(u, v);
    if (dis % 2) {
      sol[pp] = 0;
      continue;
    }
    dis /= 2;
    Q[Kth(u, dis)].push_back(make_pair(make_pair(u, v), pp));
  }
  DFS(1, -1);
  for (int j = 0; j < sol.size(); j++) cout << sol[j] << endl;
}
