#include <bits/stdc++.h>
using namespace std;
int n, jump[18][100001], u, v, d[100001];
int q, res, sz[100001], cnt, k, x, y;
vector<int> a[100001];
void DFS(int u) {
  sz[u] = 1;
  for (int v : a[u])
    if (v != jump[0][u]) {
      jump[0][v] = u;
      d[v] = d[u] + 1;
      DFS(v);
      sz[u] += sz[v];
    }
}
int lca(int u, int v) {
  int diff = d[u] - d[v];
  for (int i = 17; i >= 0; --i)
    if (diff & (1 << i)) {
      u = jump[i][u];
      res += 1 << i;
    }
  if (u == v) return u;
  for (int i = 17; i >= 0; --i)
    if (jump[i][u] != jump[i][v]) {
      u = jump[i][u];
      v = jump[i][v];
      res += (1 << (i + 1));
    }
  res += 2;
  x = u;
  y = v;
  return jump[0][u];
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    cin >> u >> v;
    ;
    a[u].push_back(v);
    a[v].push_back(u);
  }
  DFS(1);
  for (int i = 1; 1 << i <= n; ++i)
    for (int j = 1; j <= n; ++j) jump[i][j] = jump[i - 1][jump[i - 1][j]];
  cin >> q;
  while (q--) {
    cin >> u >> v;
    res = 0;
    if (d[u] < d[v]) swap(u, v);
    if (u == v) {
      cout << n << endl;
      continue;
    }
    cnt = lca(u, v);
    if (res & 1) {
      cout << 0 << endl;
      continue;
    }
    if (d[cnt] - d[u] == d[cnt] - d[v]) {
      cout << n - sz[x] - sz[y] << endl;
      continue;
    }
    res >>= 1;
    k = u;
    for (int i = 17; i >= 0; --i)
      if (res & (1 << i)) k = jump[i][k];
    res--;
    for (int i = 17; i >= 0; --i)
      if (res & (1 << i)) u = jump[i][u];
    cout << sz[k] - sz[u] << endl;
  }
}
