#include <bits/stdc++.h>
using namespace std;
const int N = 1000 * 100 + 10, L = 18;
vector<int> adj[N];
int par[N][20], d[N], h[N], n;
bool mark[N];
void DFS(int v, int p) {
  mark[v] = 1;
  par[v][0] = p;
  h[v] = h[p] + 1;
  for (int i = 1; i <= L; i++) par[v][i] = par[par[v][i - 1]][i - 1];
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i];
    if (!mark[u]) {
      DFS(u, v);
      d[v] += d[u];
    }
  }
  d[v]++;
  return;
}
int findans(int u, int t) {
  for (int i = L; i >= 0; i--) {
    if ((1 << i) & t) u = par[u][i];
  }
  return d[par[u][0]] - d[u];
}
int LCA(int v, int u) {
  if (h[u] < h[v]) swap(u, v);
  int x = u, y = v, t = h[u] - h[v], ans = 0;
  for (int i = L; i >= 0; i--) {
    int po = (1 << i);
    if (po & t) {
      ans += po;
      x = par[x][i];
    }
  }
  if (x == y) {
    if (ans % 2) return 0;
    return findans(u, ans / 2 - 1);
  }
  for (int i = L; i >= 0; i--) {
    if (par[x][i] != par[y][i]) {
      ans += (1 << i) * 2;
      x = par[x][i], y = par[y][i];
    }
  }
  if (ans % 2) return 0;
  if (h[u] == h[v]) return n - d[x] - d[y];
  return findans(u, ans / 2);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int q, u, v;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  DFS(0, 0);
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> u >> v;
    u--, v--;
    if (u == v)
      cout << n << endl;
    else
      cout << LCA(u, v) << endl;
  }
  return 0;
}
