#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 9, LOG = 20;
int n, a, b;
int h[maxn], par[LOG][maxn], siz[maxn];
vector<int> adj[maxn];
void DFS(int v, int p = -1) {
  par[0][v] = p;
  for (int i = 1; i < LOG; i++) par[i][v] = par[i - 1][par[i - 1][v]];
  siz[v] = 1;
  for (auto u : adj[v]) {
    if (u != p) {
      h[u] = h[v] + 1;
      DFS(u, v);
      siz[v] += siz[u];
    }
  }
}
int i_par(int v, int d) {
  for (int i = 0; i < LOG; i++) {
    if (d & (1 << i)) v = par[i][v];
  }
  return v;
}
int lca(int a, int b) {
  if (h[b] > h[a]) swap(a, b);
  a = i_par(a, h[a] - h[b]);
  if (a == b) return a;
  for (int i = LOG - 1; i >= 0; i--) {
    if (par[i][a] != par[i][b]) {
      a = par[i][a], b = par[i][b];
    }
  }
  return par[0][a];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y), adj[y].push_back(x);
  }
  DFS(1);
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    int p = lca(a, b);
    int x = h[a] - h[p] + h[b] - h[p];
    if (a == b) {
      cout << n << '\n';
      continue;
    }
    if (x % 2 == 1)
      cout << 0 << '\n';
    else {
      if (h[a] < h[b]) swap(a, b);
      int c = i_par(a, x / 2);
      if (c != p) {
        int d = i_par(a, x / 2 - 1);
        cout << siz[c] - siz[d] << '\n';
      } else {
        int d = i_par(a, x / 2 - 1), t = i_par(b, x / 2 - 1);
        cout << siz[c] - siz[d] - siz[t] + n - siz[c] << '\n';
      }
    }
  }
}
