#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
vector<vector<int> > g;
int depth[N], cnt[N], up[N][30], tin[N], tout[N];
int lg = 0, timer = 0, n, m, x, y;
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
int binUp(int a, int b) {
  for (int i = lg - 1; i >= 0; i--) {
    if (!upper(up[a][i], b)) {
      a = up[a][i];
    }
  }
  return a;
}
void DFS(int v, int p) {
  depth[v] = depth[p] + 1;
  cnt[v] = 1;
  tin[v] = ++timer;
  up[v][0] = p;
  for (int i = 1; i <= lg; i++) up[v][i] = up[up[v][i - 1]][i - 1];
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (to != p) {
      DFS(to, v);
      cnt[v] += cnt[to];
    }
  }
  tout[v] = ++timer;
  return;
}
int LCA(int a, int b) {
  if (upper(a, b)) {
    return a;
  }
  if (upper(b, a)) {
    return b;
  }
  a = binUp(a, b);
  return up[a][0];
}
int solve(int a, int b) {
  if (a == b) {
    return n;
  }
  int l = LCA(a, b);
  if (depth[a] - depth[l] == depth[b] - depth[l]) {
    a = binUp(a, l);
    b = binUp(b, l);
    return n - cnt[a] - cnt[b];
  }
  if (depth[a] < depth[b]) {
    swap(a, b);
  }
  int to = a;
  int dist = depth[a] + depth[b] - 2 * depth[l];
  if (dist % 2 == 1) {
    return 0;
  }
  dist /= 2;
  for (int i = lg - 1; i >= 0; i--) {
    if (depth[a] - depth[up[to][i]] < dist) {
      to = up[to][i];
    }
  }
  int tmp = up[to][0];
  return cnt[tmp] - cnt[to];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  g.resize(n);
  for (int i = 1; i < n; i++) {
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  while ((1 << lg) < n) lg++;
  depth[0] = -1;
  DFS(0, 0);
  cin >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    x--;
    y--;
    cout << solve(x, y) << endl;
  }
  return 0;
}
