#include <bits/stdc++.h>
using namespace std;
vector<long long> graph[200010];
long long dp[200010][22];
vector<bool> visited(200010, false);
vector<long long> parent(200010, -1);
vector<long long> level(200010, 0);
vector<long long> sum(200010, 0);
long long dfs(long long node) {
  visited[node] = true;
  for (auto x : graph[node]) {
    if (!visited[x]) {
      level[x] = level[node] + 1;
      parent[x] = node;
      dp[x][0] = node;
      for (long long i = 1; i < 22; i++) {
        long long curr = dp[x][i - 1];
        dp[x][i] = dp[curr][i - 1];
      }
      sum[node] += dfs(x);
    }
  }
  sum[node]++;
  return sum[node];
}
long long comp(long long a, long long b) {
  long long lv1 = level[a];
  long long lv2 = level[b];
  long long diff = abs(lv1 - lv2);
  if (lv1 < lv2) {
    swap(a, b);
  }
  for (long long i = 21; i >= 0; i--) {
    long long curr = (1LL << i);
    if (curr <= diff) {
      diff -= curr;
      a = dp[a][i];
    }
  }
  if (a == b) {
    return a;
  }
  for (long long i = 21; i >= 0; i--) {
    long long curr1 = dp[a][i];
    long long curr2 = dp[b][i];
    if (curr1 != curr2) {
      a = curr1;
      b = curr2;
    }
  }
  return a == b ? a : parent[a];
}
long long find_dist(long long node, long long ht) {
  for (long long i = 21; i >= 0; i--) {
    long long curr = (1LL << i);
    if (curr <= ht) {
      node = dp[node][i];
      ht -= curr;
    }
  }
  return node;
}
void pre(long long n) {
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < 22; j++) {
      dp[i][j] = 0;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n;
  cin >> n;
  pre(n);
  for (long long i = 0; i + 1 < n; i++) {
    long long u, v;
    cin >> u >> v;
    u--;
    v--;
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  dfs(0);
  long long q;
  cin >> q;
  while (q--) {
    long long a, b;
    cin >> a >> b;
    a--;
    b--;
    if (a == b) {
      cout << n << "\n";
    } else {
      long long lca = comp(a, b);
      long long dist = level[a] + level[b] - (2 * level[lca]);
      if (dist % 2) {
        cout << "0\n";
      } else {
        long long hf = dist / 2;
        if (level[a] == level[b]) {
          long long curr1 = find_dist(a, hf - 1);
          long long curr2 = find_dist(b, hf - 1);
          long long ans = n - sum[curr1] - sum[curr2];
          cout << ans << "\n";
        } else {
          if (level[a] < level[b]) {
            swap(a, b);
          }
          long long nd = find_dist(a, hf);
          long long curr = find_dist(a, hf - 1);
          long long ans = sum[nd] - sum[curr];
          cout << ans << "\n";
        }
      }
    }
  }
}
