#include <bits/stdc++.h>
using namespace std;
vector<int> E[100010];
int subtree[100010], d[100010];
int par[100010][18];
void dfs(int pos = 1, int prev = 0, int depth = 0) {
  subtree[pos] = 1;
  d[pos] = depth;
  par[pos][0] = prev;
  for (int i = 1; i < 18; ++i) {
    par[pos][i] = par[par[pos][i - 1]][i - 1];
    if (!par[pos][i]) break;
  }
  for (int v : E[pos]) {
    if (v != prev) {
      dfs(v, pos, depth + 1);
      subtree[pos] += subtree[v];
    }
  }
}
int LCA(int u, int v) {
  if (d[v] < d[u]) return LCA(v, u);
  int diff = d[v] - d[u];
  for (int i = 0; i < 18; ++i)
    if (diff & (1 << i)) v = par[v][i];
  if (u == v) return u;
  for (int i = 18 - 1; i >= 0; --i) {
    if (par[u][i] != par[v][i]) {
      u = par[u][i];
      v = par[v][i];
    }
  }
  return par[u][0];
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  int u, v;
  for (int i = 1; i < n; ++i) {
    cin >> u >> v;
    E[u].push_back(v);
    E[v].push_back(u);
  }
  dfs();
  int q;
  cin >> q;
  while (q--) {
    cin >> u >> v;
    int lca = LCA(u, v);
    int dist = d[u] + d[v] - (d[lca] << 1);
    if (dist & 1) {
      cout << 0 << endl;
      continue;
    }
    int ups = (dist >> 1) - 1;
    for (int i = 0; i < 18; ++i) {
      if (ups & (1 << i)) {
        u = par[u][i];
        v = par[v][i];
      }
    }
    if (d[u] == d[v]) {
      cout << n - subtree[u] - subtree[v] << endl;
      continue;
    }
    if (d[u] > d[v]) swap(u, v);
    cout << subtree[par[v][0]] - subtree[v] << endl;
  }
}
