#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
const long long int inf = 1e17;
const int mod = 1e9 + 7;
const int lg = 18;
int sz[N], h[N], par[lg][N];
vector<int> adj[N];
void dfs(int u) {
  sz[u] = 1;
  for (auto x : adj[u]) {
    if (x != par[0][u]) {
      h[x] = h[u] + 1;
      par[0][x] = u;
      for (int i = 1; i < lg; i++) par[i][x] = par[i - 1][par[i - 1][x]];
      dfs(x);
      sz[u] += sz[x];
    }
  }
  return;
}
int find_par(int x, int k) {
  for (int i = lg - 1; i >= 0; i--) {
    if ((k >> i) & 1) x = par[i][x];
  }
  return x;
}
int find_lca(int x, int y) {
  if (h[x] < h[y]) swap(x, y);
  x = find_par(x, h[x] - h[y]);
  if (x == y) return x;
  for (int i = lg - 1; i >= 0; i--) {
    if (par[i][x] != par[i][y]) {
      x = par[i][x];
      y = par[i][y];
    }
  }
  return par[0][x];
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, q;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(0);
  cin >> q;
  while (q--) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    if (h[x] < h[y]) swap(x, y);
    if (x == y) {
      cout << n << endl;
      continue;
    }
    int u = find_lca(x, y);
    int dis = h[x] + h[y] - 2 * h[u];
    if (dis % 2 == 1) {
      cout << 0 << endl;
      continue;
    }
    dis /= 2;
    int v = find_par(x, dis);
    if (v == u) {
      x = find_par(x, dis - 1);
      y = find_par(y, dis - 1);
      cout << n - sz[x] - sz[y] << endl;
      continue;
    }
    u = find_par(x, dis - 1);
    cout << sz[v] - sz[u] << endl;
  }
  return 0;
}
