#include <bits/stdc++.h>
using namespace std;
int n, l;
vector<vector<int> > g;
vector<int> tin, tout;
int timer;
vector<vector<int> > up;
vector<int> dists;
vector<int> w;
void dfs(int v, int p = 0) {
  if (p != v) dists[v] = dists[p] + 1;
  tin[v] = ++timer;
  up[v][0] = p;
  w[v] = 1;
  for (int i = 1; i <= l; ++i) up[v][i] = up[up[v][i - 1]][i - 1];
  for (size_t i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (to != p) {
      dfs(to, v);
      w[v] += w[to];
    }
  }
  tout[v] = ++timer;
}
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
int lca(int a, int b) {
  if (upper(a, b)) return a;
  if (upper(b, a)) return b;
  for (int i = l; i >= 0; --i)
    if (!upper(up[a][i], b)) a = up[a][i];
  return up[a][0];
}
int getUp(int v, int d) {
  int i = 0;
  while (d) {
    if (d & 1) v = up[v][i];
    i++;
    d >>= 1;
  }
  return v;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n;
  g.assign(n, vector<int>());
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dists.resize(n);
  w.resize(n);
  tin.resize(n), tout.resize(n), up.resize(n);
  l = 1;
  while ((1 << l) <= n) ++l;
  for (int i = 0; i < n; ++i) up[i].resize(l + 1);
  dists[0] = 0;
  dfs(0);
  cin >> m;
  for (int i = 0; i < m; i++) {
    int v1, v2;
    cin >> v1 >> v2;
    v1--, v2--;
    if (v1 == v2) {
      cout << n << endl;
      continue;
    }
    int v = lca(v1, v2);
    int dist = dists[v1] + dists[v2] - 2 * dists[v];
    int vh = dists[v];
    int d1 = dists[v1] - dists[v], d2 = dists[v2] - dists[v];
    if (d1 == d2) {
      int prevv1 = getUp(v1, d1 - 1);
      int prevv2 = getUp(v2, d2 - 1);
      cout << w[0] - w[prevv1] - w[prevv2] << endl;
    } else {
      int diff = abs(d1 - d2);
      if (diff & 1) {
        cout << 0 << endl;
        continue;
      }
      int upp;
      int v_, prevv_;
      if (d1 > d2) {
        upp = d1 - diff / 2;
        v_ = getUp(v1, upp);
        prevv_ = getUp(v1, upp - 1);
      } else {
        upp = d2 - diff / 2;
        v_ = getUp(v2, upp);
        prevv_ = getUp(v2, upp - 1);
      }
      cout << w[v_] - w[prevv_] << endl;
    }
  }
  return 0;
}
