#include <bits/stdc++.h>   using namespace std;   int in() {     int n;     scanf( %d , &n);     return n;   }   long long Lin() {     long long n;     scanf( %lld , &n);     return n;   }   double Din() {     double n;     scanf( %lf , &n);     return n;   }   const long long inf = (long long)1e17;   const long long mod = (long long)1e9 + 7;   const int N = 1e5 + 5;   vector<int> g[N];   bool vis[N];   int par[18][N], dep[N], sz[N];   void lca_build(int u, int d = 0) {     vis[u] = true, dep[u] = d, sz[u] = 1;     for (int i = 1; i <= 17; i++) {       par[i][u] = par[i - 1][par[i - 1][u]];     }     for (int i = 0; i < g[u].size(); i++) {       int v = g[u][i];       if (!vis[v]) {         par[0][v] = u;         lca_build(v, dep[u] + 1);         sz[u] += sz[v];       }     }   }   int lca_query(int u, int v) {     if (dep[u] < dep[v]) swap(u, v);     for (int i = 17; i >= 0 && u != v; i--) {       if (dep[par[i][u]] >= dep[v]) u = par[i][u];     }     if (u == v) return u;     for (int i = 17; i >= 0; i--) {       if (par[i][u] != par[i][v]) u = par[i][u], v = par[i][v];     }     return par[0][u];   }   int lifting(int u, int p) {     for (int i = 17; i >= 0; i--) {       if ((1 << i) <= p) u = par[i][u], p -= (1 << i);     }     return u;   }   int dis(int u, int v, int l) { return dep[u] + dep[v] - 2 * dep[l]; }   int solve() {     int n = in();     for (int i = 1; i < n; i++) {       int u = in(), v = in();       g[u].push_back(v);       g[v].push_back(u);     }     par[0][1] = 1;     lca_build(1);     int q = in();     while (q--) {       int u = in(), v = in();       int l = lca_query(u, v);       int d = dis(u, v, l);       int ans = 0;       if (u == v) {         ans = n;       } else if (d & 1) {         ans = 0;       } else if (dep[u] == dep[v]) {         int x = lifting(u, d / 2 - 1);         int y = lifting(v, d / 2 - 1);         ans = n - sz[x] - sz[y];       } else if (dep[u] > dep[v]) {         int x = lifting(u, d / 2);         int y = lifting(u, d / 2 - 1);         ans = sz[x] - sz[y];       } else {         int x = lifting(v, d / 2);         int y = lifting(v, d / 2 - 1);         ans = sz[x] - sz[y];       }       printf( %d n , ans);     }     return 0;   }   int main() {     int test = 1, tc = 0;     while (test--) {       solve();     }     return 0;   }   