#include <bits/stdc++.h>
using namespace std;
const long long size = 100007;
const long long modulo = 1000000007;
const int oo = 1e9;
const double EPS = 1e-2;
const double PI = acos(-1.0);
int maxLen = 0;
int anc[size][22];
int subSize[size], height[size];
int tin[size], tout[size];
int timer;
vector<vector<int> > g;
void dfs(int v, int h, int from = -1) {
  tin[v] = ++timer;
  height[v] = h;
  if (from >= 0) {
    anc[v][0] = from;
    for (int i = 1; i <= maxLen; i++) anc[v][i] = anc[anc[v][i - 1]][i - 1];
  }
  subSize[v] = 1;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (to != from) {
      dfs(to, h + 1, v);
      subSize[v] += subSize[to];
    }
  }
  tout[v] = ++timer;
}
int ancestor(int v, int n) {
  int cur = maxLen;
  if (n == 0) return v;
  while (cur > 0) {
    if ((1 << cur) > n)
      --cur;
    else {
      v = anc[v][cur];
      n -= (1 << cur);
      --cur;
    }
  }
  return n == 1 ? anc[v][0] : v;
}
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 = maxLen; i >= 0; --i)
    if (!upper(anc[a][i], b)) a = anc[a][i];
  return anc[a][0];
}
int main() {
  int n;
  cin >> n;
  g.resize(n);
  while ((1 << (maxLen + 1)) <= n) ++maxLen;
  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);
  }
  dfs(0, 0);
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    int ans = 0;
    --a;
    --b;
    if (a == b)
      cout << n << endl;
    else {
      int lc = lca(a, b);
      if (lc != a && lc != b) {
        if (height[a] == height[b]) {
          int needed = height[b] - height[lc] - 1;
          ans = n - subSize[ancestor(b, needed)] - subSize[ancestor(a, needed)];
        } else if (abs(height[a] - height[b]) % 2 == 0) {
          int total = 2 * height[lc] - height[a] - height[b];
          int la = height[a] - height[lc], lb = height[b] - height[lc];
          if (la < lb) {
            int needed = lb - (lb - la) / 2;
            int mid = ancestor(b, needed), pre = ancestor(b, needed - 1);
            ans = subSize[mid] - subSize[pre];
          } else {
            int needed = la - (la - lb) / 2;
            int mid = ancestor(a, needed);
            ans = subSize[mid] - subSize[ancestor(a, needed - 1)];
          }
        } else
          ans = 0;
      } else if (abs(height[a] - height[b]) % 2 == 0) {
        if (height[a] < height[b]) {
          int needed = (height[b] - height[a]) / 2;
          int mid = ancestor(b, needed);
          ans = subSize[mid] - subSize[ancestor(b, needed - 1)];
        } else {
          int needed = (height[a] - height[b]) / 2;
          int mid = ancestor(a, needed);
          ans = subSize[mid] - subSize[ancestor(a, needed - 1)];
        }
      }
      cout << ans << endl;
    }
  }
  return 0;
}
