#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int add(int x, int y, int CMOD = MOD) { return (0LL + x + y) % CMOD; }
int mult(int x, int y, int CMOD = MOD) { return (1LL * x * y) % CMOD; }
long long fast_expo(long long x, long long y, long long CMOD = MOD) {
  if (x == 0) return 0;
  if (y == 0) return 1;
  long long ans = fast_expo(x, y / 2, CMOD);
  ans = mult(ans, ans, CMOD);
  if (y & 1) ans = mult(ans, x, CMOD);
  return ans;
}
const int TAM = 1e5 + 100;
const int L = 19;
int n;
vector<int> G[TAM];
int sub[TAM];
int in[TAM];
int out[TAM];
int timer = 0;
int h[TAM];
int up[TAM][L];
void dfs(int u, int pd, int alt) {
  in[u] = timer++;
  sub[u] = 1, h[u] = alt;
  up[u][0] = pd;
  for (int i = 1; i < L; i++) up[u][i] = up[up[u][i - 1]][i - 1];
  for (int v : G[u]) {
    if (v != pd) {
      dfs(v, u, alt + 1);
      sub[u] += sub[v];
    }
  }
  out[u] = timer++;
}
bool isAncestor(int u, int v) { return (in[u] <= in[v] and out[v] <= out[u]); }
int lca(int u, int v) {
  if (isAncestor(u, v)) return u;
  if (isAncestor(v, u)) return v;
  for (int i = L - 1; i >= 0; i--) {
    if (!isAncestor(up[u][i], v)) u = up[u][i];
  }
  return up[u][0];
}
int subir(int u, int t) {
  for (int i = L - 1; i >= 0; i--) {
    if (t - (1 << i) >= 0) {
      u = up[u][i];
      t -= (1 << i);
    }
  }
  return u;
}
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }
  dfs(0, 0, 0);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    if (h[u] < h[v]) swap(u, v);
    int l = lca(u, v);
    int dis = h[u] + h[v] - 2 * h[l];
    if (dis % 2 != 0) {
      cout << "0\n";
      continue;
    }
    if (u == v) {
      cout << n << "\n";
      continue;
    }
    if (h[v] == h[u]) {
      u = subir(u, h[u] - h[l] - 1);
      v = subir(v, h[v] - h[l] - 1);
      cout << n - sub[u] - sub[v] << endl;
    } else {
      u = subir(u, dis / 2 - 1);
      int ans = -sub[u];
      u = up[u][0];
      ans += sub[u];
      cout << ans << endl;
    }
  }
  return 0;
}
