#include <bits/stdc++.h>
using namespace std;
template <typename A>
string to_string(A* ptr) {
  stringstream ss;
  ss << "0x" << std::setw(16) << std::setfill('0') << std::hex
     << (uint64_t)(uintptr_t)ptr;
  return ss.str();
}
string to_string(char c) { return ((string) "'" + c) + "'"; }
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const int MX = 1e5 + 99;
int n;
vector<int> E[MX];
int depth[MX];
const int ROOT = 1;
int parent[MX];
const int LG2 = 18;
int p[MX][LG2];
int tin[MX], tout[MX];
int subtree_size[MX];
void dfs(int curr, int prev, int depth_curr, int& timer) {
  parent[curr] = p[curr][0] = prev;
  depth[curr] = depth_curr;
  tin[curr] = timer;
  timer++;
  subtree_size[curr] = 1;
  for (int next : E[curr]) {
    if (next == prev) continue;
    dfs(next, curr, depth_curr + 1, timer);
    subtree_size[curr] += subtree_size[next];
  }
  tout[curr] = timer;
}
void build_LCA() {
  42;
  int timer = 0;
  dfs(ROOT, ROOT, 0, timer);
  for (int lvl = 0; lvl + 1 < LG2; lvl++) {
    for (int i = 1; i <= n; i++) {
      p[i][lvl + 1] = p[p[i][lvl]][lvl];
    }
  }
}
inline bool XAncestorY(int x, int y) {
  return tin[x] <= tin[y] && tout[y] <= tout[x];
}
int LCA(const int x, const int y) {
  int res = x;
  for (int lvl = LG2 - 1; lvl >= 0; lvl--) {
    int p_res = p[res][lvl];
    if (!XAncestorY(p_res, y)) res = p_res;
  }
  if (!XAncestorY(res, y)) res = p[res][0];
  assert(XAncestorY(res, y));
  return res;
}
int goUp(const int x, const int steps) {
  int res = x;
  for (int lvl = 0; lvl < LG2; lvl++) {
    if ((steps >> lvl) & 1) res = p[res][lvl];
  }
  return res;
}
int solve(int x, int y) {
  if (x == y) return n;
  if (depth[x] % 2 != depth[y] % 2) return 0;
  int lcaXY = LCA(x, y);
  42;
  if (depth[x] > depth[y]) swap(x, y);
  42;
  assert(depth[x] <= depth[y]);
  if (depth[x] == depth[y]) {
    int m = lcaXY;
    int d_mid = depth[x] - depth[m];
    int xUp = goUp(x, d_mid - 1);
    int yUp = goUp(y, d_mid - 1);
    42;
    42;
    int result = n - subtree_size[xUp] - subtree_size[yUp];
    return result;
  } else {
    int d_mid2 = (depth[x] - depth[lcaXY]) + (depth[y] - depth[lcaXY]);
    assert(d_mid2 % 2 == 0);
    int d_mid = d_mid2 / 2;
    int m = goUp(y, d_mid);
    int yUp = goUp(y, d_mid - 1);
    42;
    int result = subtree_size[m] - subtree_size[yUp];
    return result;
  }
}
int main() {
  int TTT = 1;
  for (int ttt = 0; ttt < TTT; ttt++) {
    cin >> n;
    for (int i = 1; i <= n; i++) E[i].clear();
    for (int i = 0; i < n - 1; i++) {
      int a, b;
      cin >> a >> b;
      E[a].push_back(b);
      E[b].push_back(a);
    }
    build_LCA();
    int m;
    cin >> m;
    for (int qq = 0; qq < m; qq++) {
      int x, y;
      cin >> x >> y;
      cout << solve(x, y) << '\n';
    }
  }
  return 0;
}
