#include <bits/stdc++.h>   const long double eps = 1e-9;   using namespace std;   template <class T>   inline T MAX(const T &_a, const T &_b) {     return ((_a > _b) ? _a : _b);   }   template <class T>   inline T MIN(const T &_a, const T &_b) {     return ((_a < _b) ? _a : _b);   }   template <class T>   inline T MAX3(const T &_a, const T &_b, const T &_c) {     return MAX(MAX(_a, _b), _c);   }   template <class T>   inline T MIN3(const T &_a, const T &_b, const T &_c) {     return MIN(MIN(_a, _b), _c);   }   template <class T>   inline T MAX4(const T &_a, const T &_b, const T &_c, const T &_d) {     return MAX(MAX3(_a, _b, _c), _d);   }   template <class T>   inline T MIN4(const T &_a, const T &_b, const T &_c, const T &_d) {     return MIN(MIN3(_a, _b, _c), _d);   }   template <class T>   inline T ABS(const T &_a) {     return ((_a < 0) ? -_a : _a);   }   template <class T>   inline T SQR(const T &_a) {     return _a * _a;   }   template <class T>   inline T gcd(T _a, T _b) {     for (T _r; (_r = _a % _b); _b = _r) _a = _b;     return _b;   }   template <class T>   inline T lcm(const T &_a, const T &_b) {     return (_a / gcd(_a, _b)) * _b;   }   template <class T>   inline bool BETW(const T &_a, const T &_b, const T &_c) {     return (_a >= MIN(_b, _c) && _a <= MAX(_b, _c));   }   template <class T>   inline bool EXT(const T &_a, const T &_b, const T &_c) {     return !BETW(_a, _b, _c);   }   const int MAXN = 100010, MAXL = 20;   int N, father[MAXL][MAXN], level[MAXN], subTree[MAXN];   vector<int> adj[MAXN];   void dfs(int node, int prev) {     int i;     father[0][node] = prev;     level[node] = level[prev] + 1;     subTree[node] = 1;     for (i = 0; i < ((int)adj[node].size()); i++)       if (adj[node][i] != prev) {         dfs(adj[node][i], node);         subTree[node] += subTree[adj[node][i]];       }   }   inline int LCA(int a, int b) {     int k;     if (level[a] < level[b]) swap(a, b);     k = MAXL - 1;     while (level[a] > level[b]) {       while (k && level[father[k][a]] < level[b]) k--;       a = father[k][a];     }     k = MAXL - 1;     while (a != b) {       while (k && father[k][a] == father[k][b]) k--;       a = father[k][a];       b = father[k][b];     }     return a;   }   inline int getFather(int a, int H) {     for (int k = MAXL - 1; k >= 0; k--)       if (H >= (1 << k)) {         a = father[k][a];         H -= (1 << k);       }     return a;   }   int main() {     int i, a, b, k, q, ab, x, y;     scanf( %d , &N);     for (i = 1; i < N; i++) {       scanf( %d%d , &a, &b);       adj[a].push_back(b);       adj[b].push_back(a);     }     dfs(1, 0);     for (k = 1; k < MAXL; k++)       for (i = 1; i <= N; i++) father[k][i] = father[k - 1][father[k - 1][i]];     scanf( %d , &q);     while (q--) {       scanf( %d%d , &a, &b);       ab = LCA(a, b);       if ((level[a] - level[ab] + level[b] - level[ab]) & 1) {         puts( 0 );         continue;       }       if (level[a] < level[b]) swap(a, b);       if (a == b) {         printf( %d n , N);         continue;       }       if (level[a] == level[b]) {         x = getFather(a, level[a] - level[ab] - 1);         y = getFather(b, level[a] - level[ab] - 1);         printf( %d n , N - subTree[x] - subTree[y]);       } else {         x = getFather(a, (level[a] - level[ab] + level[b] - level[ab]) / 2 - 1);         printf( %d n , subTree[father[0][x]] - subTree[x]);       }     }     return 0;   }