#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 10, INF = 1e18;
int T, c;
int n;
vector<int> g[N], depth, sub, up[N];
void dfs(int u, int par = 0) {
  up[u][0] = par;
  for (int i = 1; i < 18; i++) {
    up[u][i] = up[up[u][i - 1]][i - 1];
  }
  for (auto v : g[u]) {
    if (v != par) {
      depth[v] = depth[u] + 1;
      dfs(v, u);
      sub[u] += sub[v];
    }
  }
}
vector<int> get_lca(int a, int b) {
  if (depth[a] < depth[b]) swap(a, b);
  int k = depth[a] - depth[b];
  for (int i = 17; i >= 0; i--) {
    if ((1 << i) < k) {
      a = up[a][i];
      k -= 1 << i;
    }
  }
  if (up[a][0] == b) {
    return {up[a][0], a};
  }
  if (k > 0) a = up[a][0];
  for (int i = 17; i >= 0; i--) {
    if (up[a][i] != up[b][i]) {
      a = up[a][i];
      b = up[b][i];
    }
  }
  return {up[a][0], a, b};
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  fill(up, up + n + 1, vector<int>(18, 0));
  depth.resize(n + 1);
  sub.assign(n + 1, 1);
  dfs(1);
  int m;
  cin >> m;
  while (m--) {
    int a, b;
    cin >> a >> b;
    auto res = get_lca(a, b);
    int lca = res[0];
    int d = depth[a] + depth[b] - 2 * depth[lca];
    if (a == b) {
      cout << n << '\n';
      continue;
    }
    if (d & 1) {
      cout << "0\n";
      continue;
    }
    if (depth[a] == depth[b]) {
      cout << n - sub[res[1]] - sub[res[2]] << '\n';
      continue;
    }
    d >>= 1;
    if (depth[a] < depth[b]) swap(a, b);
    for (int i = 17; i >= 0; i--) {
      if ((1 << i) < d) {
        a = up[a][i];
        d -= 1 << i;
      }
    }
    cout << sub[up[a][0]] - sub[a] << '\n';
  }
}
