#include <bits/stdc++.h>   using namespace std;   const int MAXN = 100005;   const long long oo = ((long long)1e18) + 7;   int N, M, T, K, Q;   vector<int> G[MAXN];   int num[MAXN];   int dep[MAXN];   int pa[MAXN][25];   int LOG = 20;   int cnt = 0;   int child[MAXN];   int DFS(int u, int par, int depth) {     num[u] = ++cnt;     dep[num[u]] = depth;     pa[num[u]][0] = num[par];     for (auto v : G[u])       if (v != par) {         child[num[u]] += DFS(v, u, dep[num[u]] + 1);       }     return child[num[u]];   }   int LCA(int u, int v) {     if (u == v) return u;     if (dep[u] < dep[v]) swap(u, v);     for (int i = LOG; i >= 0; i--)       if (dep[pa[u][i]] >= dep[v]) u = pa[u][i];     if (u == v) return u;     for (int i = LOG; i >= 0; i--)       if (pa[u][i] != pa[v][i]) {         u = pa[u][i];         v = pa[v][i];       }     return pa[u][0];   }   int findParent(int u, int k) {     if (k == 0) return u;     int i = 0;     while (k > 0) {       if (k & 1) u = pa[u][i];       i++;       k >>= 1;     }     return u;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cout.tie(0);     if (fopen( 519E                 .inp ,                r )) {       freopen(            519E             .inp ,            r , stdin);       freopen(            519E             .out ,            w , stdout);     }     cin >> N;     for (int i = 1; i < N; i++) {       int u, v;       cin >> u >> v;       G[u].push_back(v);       G[v].push_back(u);     }     for (int i = 1; i <= N; i++) child[i] = 1;     dep[0] = -1;     DFS(1, 0, 0);     for (int k = 1; k <= LOG; k++)       for (int i = 1; i <= N; i++) pa[i][k] = pa[pa[i][k - 1]][k - 1];     cin >> Q;     while (Q--) {       int u, v;       cin >> u >> v;       u = num[u];       v = num[v];       if (dep[u] < dep[v]) swap(u, v);       int p = LCA(u, v);       if (u == v) {         cout << N <<   n ;         continue;       }       int diff1 = dep[u] - dep[p];       int diff2 = dep[v] - dep[p];       if ((diff1 + diff2) & 1) {         cout << 0 <<   n ;         continue;       }       int avg = (diff1 + diff2) >> 1;       int mid = findParent(u, avg);       if (mid == p) {         int fakeParent1 = findParent(u, diff1 - 1);         int fakeParent2 = findParent(v, diff2 - 1);         cout << (child[mid] - child[fakeParent1] - child[fakeParent2]) + N -                     child[mid]              <<   n ;         continue;       }       diff1 = dep[u] - dep[mid];       int fakeParent1 = findParent(u, diff1 - 1);       cout << child[mid] - child[fakeParent1] <<   n ;     }   }   