#include <bits/stdc++.h>
const long long md = 1e9 + 7;
const int Inf = 1e9;
const long long Inf64 = 1e18;
const long long MaxN = 1e5 + 10;
const long long LogN = 21;
const long long MaxM = 5e5 + 10;
const long double eps = 1e-7;
const long long dx[4] = {0, 1, 0, -1};
const long long dy[4] = {1, 0, -1, 0};
const long long ddx[4] = {1, 1, -1, -1};
const long long ddy[4] = {1, -1, 1, -1};
const long double Pi = acos(-1);
using namespace std;
template <typename T>
istream &operator>>(istream &in, pair<T, T> &a) {
  in >> a.first >> a.second;
  return in;
}
template <typename T>
ostream &operator<<(ostream &out, pair<T, T> a) {
  out << a.first << ' ' << a.second;
  return out;
}
template <typename T>
istream &operator>>(istream &in, vector<T> &Mt) {
  for (T &a : Mt) in >> a;
  return in;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> Mt) {
  for (int i = 0; i < Mt.size(); i++) {
    out << Mt[i];
    if (i != Mt.size()) out << ' ';
  }
  out << '\n';
  return out;
}
inline long long Mod(long long &a, long long m = md) {
  while (a >= m) a -= m;
  return a;
}
inline long long gcd(long long a, long long b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}
inline long long gcdex(long long a, long long mod = md) {
  long long g = mod, r = a, x = 0, y = 1;
  while (r != 0) {
    long long q = g / r;
    g %= r;
    swap(g, r);
    x -= q * y;
    swap(x, y);
  }
  return x < 0 ? x + mod : x;
}
inline long long binpow(long long a, long long n, long long m = md) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res *= a;
      res %= m;
    }
    a *= a;
    a %= m;
    n >>= 1;
  }
  return res % md;
}
vector<long long> Gr[MaxN];
long long dep[MaxN];
long long dp[MaxN][LogN];
long long Size[MaxN];
long long dfs(long long v, long long p = 0) {
  dp[v][0] = p;
  for (int i = 1; i < LogN; i++) {
    dp[v][i] = dp[dp[v][i - 1]][i - 1];
  }
  dep[v] = dep[p] + 1;
  long long s = 1;
  for (long long to : Gr[v]) {
    if (to == p) continue;
    s += dfs(to, v);
  }
  Size[v] = s;
  return s;
}
long long LCA(long long a, long long b) {
  if (dep[b] > dep[a]) swap(a, b);
  for (int i = LogN - 1; i >= 0; i--) {
    if (dep[dp[a][i]] >= dep[b]) {
      a = dp[a][i];
    }
  }
  if (a != b) {
    for (int i = LogN - 1; i >= 0; i--) {
      if (dp[a][i] != dp[b][i]) {
        a = dp[a][i];
        b = dp[b][i];
      }
    }
    a = dp[a][0];
    b = dp[b][0];
  }
  return b;
}
long long dist(long long a, long long b) { return dep[a] - dep[b]; }
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed, cout.precision(20);
  {
    long long N;
    cin >> N;
    for (int i = 0; i < N - 1; i++) {
      long long a, b;
      cin >> a >> b;
      Gr[a].push_back(b);
      Gr[b].push_back(a);
    }
    dfs(1, 0);
    long long Q;
    cin >> Q;
    while (Q--) {
      long long a, b;
      cin >> a >> b;
      if (a == b) {
        cout << N << '\n';
        continue;
      }
      long long l = LCA(a, b);
      long long da = dist(a, l);
      long long db = dist(b, l);
      if ((da + db) & 1) {
        cout << 0 << '\n';
        continue;
      }
      if (da == db) {
        da--;
        db--;
        long long t = a;
        long long k = b;
        for (int i = LogN - 1; i >= 0; i--) {
          if ((1 << i) <= da) {
            k = dp[k][i];
            t = dp[t][i];
            da -= 1 << i;
          }
        }
        cout << N - Size[k] - Size[t] << '\n';
        continue;
      }
      if (dep[a] < dep[b]) swap(a, b);
      long long d = da + db;
      long long t = d / 2;
      long long k = d / 2 - 1;
      long long v = a;
      long long u = a;
      for (int i = LogN - 1; i >= 0; i--) {
        if ((1 << i) <= t) {
          v = dp[v][i];
          t -= (1 << i);
        }
      }
      for (int i = LogN - 1; i >= 0; i--) {
        if ((1 << i) <= k) {
          u = dp[u][i];
          k -= (1 << i);
        }
      }
      cout << Size[v] - Size[u] << '\n';
    }
  }
END:
  return 0;
}
