#include <bits/stdc++.h>
using namespace std;
vector<int> g[100100];
int bin_up[100100][17];
int h[100100];
int sz[100100];
int tin[100100];
int tout[100100];
int sum[100100];
int timer = 0;
bool is_par(int p, int x) { return tin[p] < tin[x] && tout[x] < tout[p]; }
int cnt_sz(int a, int b) {
  if (is_par(a, b)) {
    for (int lvl = 16; lvl >= 0; lvl--) {
      if (h[bin_up[b][lvl]] > h[a]) {
        b = bin_up[b][lvl];
      }
    }
    return sz[b];
  } else {
    int ans = sz[1] - 1 - sum[a];
    return ans;
  }
}
int get_mid(int a, int b) {
  if (a == b) {
    return sz[1];
  }
  if (h[a] < h[b]) {
    swap(a, b);
  }
  int sa = a;
  int sb = b;
  for (int lvl = 16; lvl >= 0; lvl--) {
    if (h[a] - (1 << lvl) >= h[b]) {
      a = bin_up[a][lvl];
    }
  }
  if (a != b) {
    for (int lvl = 16; lvl >= 0; lvl--) {
      if (bin_up[a][lvl] != bin_up[b][lvl]) {
        a = bin_up[a][lvl];
        b = bin_up[b][lvl];
      }
    }
    a = bin_up[a][0];
  }
  int lca = a;
  int dist = h[sa] - h[lca] + h[sb] - h[lca];
  if (dist & 1) {
    return 0;
  }
  dist /= 2;
  int mid = sa;
  for (int lvl = 16; lvl >= 0; lvl--) {
    if (dist >= (1 << lvl)) {
      dist -= (1 << lvl);
      mid = bin_up[mid][lvl];
    }
  }
  return sz[1] - cnt_sz(mid, sa) - cnt_sz(mid, sb);
}
void dfs(int v, int p) {
  tin[v] = timer++;
  bin_up[v][0] = p == -1 ? v : p;
  for (int lvl = 0; lvl < 16; lvl++) {
    bin_up[v][lvl + 1] = bin_up[bin_up[v][lvl]][lvl];
  }
  sz[v] = 1;
  for (auto u : g[v]) {
    if (u == p) continue;
    h[u] = h[v] + 1;
    dfs(u, v);
    sz[v] += sz[u];
  }
  for (auto u : g[v]) {
    if (h[u] > h[v]) {
      sum[v] += sz[u];
    }
  }
  tout[v] = timer++;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1, -1);
  int m;
  cin >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    cout << get_mid(a, b) << "\n";
  }
  return 0;
}
