#include <bits/stdc++.h>
using namespace std;
const long long int logx = 30;
const long long int N = 1e5 + 5;
const long long int INF = 1e18 + 5;
const long long int mod = 321555123;
const double PI = 3.14159265358979323846;
inline long long int mul(long long int a, long long int b) {
  return (a * 1ll * b) % mod;
}
inline long long int sub(long long int a, long long int b) {
  long long int c = a - b;
  if (c < 0) c += mod;
  return c;
}
inline long long int add(long long int a, long long int b) {
  long long int c = a + b;
  if (c > mod) c -= mod;
  return c;
}
template <typename T>
T power(T x, T y, long long int m) {
  T ans = 1;
  while (y > 0) {
    if (y & 1LL) ans = (ans * x) % m;
    y >>= 1ll;
    x = (x * x) % m;
  }
  return ans % m;
}
vector<long long int> g[N];
long long int n, m, q, x, y, lev[N], siz[N], p[N][logx];
void DFS(long long int cur, long long int par) {
  siz[cur] = 1;
  p[cur][0] = par;
  lev[cur] = lev[par] + 1;
  for (auto i : g[cur]) {
    if (i == par) {
      continue;
    }
    DFS(i, cur);
    siz[cur] += siz[i];
  }
}
void PreComputation() {
  for (long long int i = 1; i < logx; i++) {
    for (long long int j = 1; j <= n; j++) {
      if (p[j][i - 1] == 0) {
        continue;
      }
      p[j][i] = p[p[j][i - 1]][i - 1];
    }
  }
}
long long int LCA(long long int u, long long int v) {
  if (lev[u] > lev[v]) {
    swap(u, v);
  }
  for (long long int i = logx - 1; i >= 0; i--) {
    if (lev[p[v][i]] >= lev[u]) {
      v = p[v][i];
    }
  }
  if (u == v) {
    return u;
  }
  for (long long int i = logx - 1; i >= 0; i--) {
    if (p[u][i] != 0 && p[u][i] != p[v][i]) {
      u = p[u][i];
      v = p[v][i];
    }
  }
  x = u;
  y = v;
  return p[u][0];
}
long long int GoUp(long long int node, long long int dis) {
  if (dis == 0) {
    return node;
  }
  for (long long int i = logx - 1; i >= 0; i--) {
    if (dis - (1 << i) >= 1) {
      node = p[node][i];
      dis -= (1 << i);
    }
  }
  return p[node][0];
}
int main() {
  cin >> n;
  m = n - 1;
  while (m--) {
    long long int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  DFS(1, 0);
  PreComputation();
  cin >> q;
  while (q--) {
    long long int u, v;
    cin >> u >> v;
    long long int lca = LCA(u, v);
    long long int tot = lev[u] + lev[v] - (2 * lev[lca]);
    long long int udis = lev[u] - lev[lca];
    long long int vdis = lev[v] - lev[lca];
    if (tot % 2) {
      cout << 0 << endl;
      continue;
    }
    if (u == v) {
      cout << n << endl;
      continue;
    }
    if (udis == vdis) {
      long long int nodes = n;
      long long int remove = siz[x] + siz[y];
      cout << nodes - remove << endl;
    } else {
      long long int mid = (tot) / 2;
      if (udis < mid) {
        long long int node = GoUp(v, mid);
        long long int uremove = n - siz[node];
        long long int vremove = GoUp(v, mid - 1);
        cout << n - (uremove + siz[vremove]) << endl;
      } else {
        long long int node = GoUp(u, mid);
        long long int uremove = n - siz[node];
        long long int vremove = GoUp(u, mid - 1);
        cout << n - (uremove + siz[vremove]) << endl;
      }
    }
  }
}
