#include <bits/stdc++.h>
using namespace std;
const long long inf = 2e18;
const long long mod = 1e9 + 7;
const long long MAX = 2e5 + 3;
long long prof[MAX];
long long alt[MAX][20];
vector<long long> adj[MAX];
long long tam[MAX];
void dfs(long long u) {
  for (long long i = 1; i < 20; i++) {
    alt[u][i] = alt[alt[u][i - 1]][i - 1];
  }
  for (auto v : adj[u]) {
    if (v == alt[u][0]) continue;
    alt[v][0] = u;
    prof[v] = prof[u] + 1;
    dfs(v);
  }
}
void dfs2(long long u, long long p) {
  tam[u] = 1;
  for (auto v : adj[u]) {
    if (v == p) continue;
    dfs2(v, u);
    tam[u] += tam[v];
  }
}
long long jump(long long u, long long pos) {
  for (long long i = 0; i < 20; i++) {
    if ((pos >> i) & 1) {
      u = alt[u][i];
    }
  }
  return u;
}
long long lca(long long a, long long b) {
  if (prof[a] < prof[b]) swap(a, b);
  a = jump(a, prof[a] - prof[b]);
  if (a == b) return a;
  for (long long i = 19; i >= 0; i--) {
    long long x = alt[a][i], y = alt[b][i];
    if (x != y) a = x, b = y;
  }
  return alt[a][0];
}
long long dis(long long x, long long y) {
  return prof[x] + prof[y] - 2 * prof[lca(x, y)];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n;
  cin >> n;
  for (long long i = 1; i < n; i++) {
    long long u, v;
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1);
  dfs2(1, 0);
  long long q;
  cin >> q;
  while (q--) {
    long long u, v;
    cin >> u >> v;
    if (u == v) {
      cout << n << "\n";
      continue;
    }
    if ((dis(u, v) & 1)) {
      cout << "0\n";
      continue;
    }
    long long res = dis(u, v);
    res /= 2;
    long long aux = lca(u, v);
    if (prof[u] < prof[v]) swap(u, v);
    if (dis(u, aux) == dis(v, aux)) {
      long long a = jump(u, res - 1);
      long long b = jump(v, res - 1);
      cout << n - (tam[a] + tam[b]) << "\n";
      continue;
    }
    long long xd = jump(u, res - 1);
    cout << tam[alt[xd][0]] - tam[xd] << "\n";
  }
  return 0;
}
