#include <bits/stdc++.h>
template <typename T>
class IntegerIterator {
 public:
  using value_type = T;
  using difference_type = std::ptrdiff_t;
  using pointer = T *;
  using reference = T;
  using iterator_category = std::input_iterator_tag;
  explicit IntegerIterator(T value) : value(value) {}
  IntegerIterator &operator++() {
    ++value;
    return *this;
  }
  IntegerIterator operator++(int) {
    IntegerIterator copy = *this;
    ++value;
    return copy;
  }
  IntegerIterator &operator--() {
    --value;
    return *this;
  }
  IntegerIterator operator--(int) {
    IntegerIterator copy = *this;
    --value;
    return copy;
  }
  T operator*() const { return value; }
  bool operator==(IntegerIterator rhs) const { return value == rhs.value; }
  bool operator!=(IntegerIterator rhs) const { return !(*this == rhs); }

 private:
  T value;
};
template <typename T>
class IntegerRange {
 public:
  IntegerRange(T begin, T end) : begin_(begin), end_(end) { ; }
  IntegerIterator<T> begin() const { return IntegerIterator<T>(begin_); }
  IntegerIterator<T> end() const { return IntegerIterator<T>(end_); }

 private:
  T begin_;
  T end_;
};
template <typename T>
class ReversedIntegerRange {
  using IteratorType = std::reverse_iterator<IntegerIterator<T>>;

 public:
  ReversedIntegerRange(T begin, T end) : begin_(begin), end_(end) { ; }
  IteratorType begin() const {
    return IteratorType(IntegerIterator<T>(begin_));
  }
  IteratorType end() const { return IteratorType(IntegerIterator<T>(end_)); }

 private:
  T begin_;
  T end_;
};
template <typename T>
IntegerRange<T> range(T to) {
  return IntegerRange<T>(0, to);
}
template <typename T>
IntegerRange<T> range(T from, T to) {
  return IntegerRange<T>(from, to);
}
template <typename T>
IntegerRange<T> inclusiveRange(T to) {
  return IntegerRange<T>(0, to + 1);
}
template <typename T>
IntegerRange<T> inclusiveRange(T from, T to) {
  return IntegerRange<T>(from, to + 1);
}
template <typename T>
ReversedIntegerRange<T> downrange(T from) {
  return ReversedIntegerRange<T>(from, 0);
}
template <typename T>
ReversedIntegerRange<T> downrange(T from, T to) {
  return ReversedIntegerRange<T>(from, to);
}
template <typename T>
ReversedIntegerRange<T> inclusiveDownrange(T from) {
  return ReversedIntegerRange<T>(from + 1, 0);
}
template <typename T>
ReversedIntegerRange<T> inclusiveDownrange(T from, T to) {
  return ReversedIntegerRange<T>(from + 1, to);
}
namespace impl {
using Random = std::mt19937;
}
inline impl::Random &randomEngine() {
  static std::random_device device;
  static impl::Random engine(device());
  return engine;
}
inline int randomInteger() {
  std::uniform_int_distribution<int> d;
  return d(randomEngine());
}
inline int randomInteger(int to) {
  ;
  std::uniform_int_distribution<int> d(0, to - 1);
  return d(randomEngine());
}
inline int randomInteger(int from, int to) {
  return from + randomInteger(to - from);
}
using namespace std;
class EAAndBAndLectureRooms {
  const int LOG = 20;
  vector<vector<int>> graph, P;
  vector<int> size, H;
  int dfs(int u, int p, int h) {
    H[u] = h;
    P[0][u] = p;
    int &res = size[u] = 1;
    for (int v : graph[u]) {
      if (v != p) {
        res += dfs(v, u, h + 1);
      }
    }
    return res;
  }
  void init() {
    dfs(0, 0, 0);
    int n = graph.size();
    for (int l : range(1, LOG)) {
      for (int i : range(n)) {
        P[l][i] = P[l - 1][P[l - 1][i]];
      }
    }
  }
  int lca(int u, int v) {
    if (H[u] < H[v]) {
      swap(u, v);
    }
    for (int l : downrange(LOG)) {
      if (H[P[l][u]] >= H[v]) {
        u = P[l][u];
      }
    }
    if (u == v) {
      return u;
    }
    for (int l : downrange(LOG)) {
      if (P[l][u] != P[l][v]) {
        u = P[l][u];
        v = P[l][v];
      }
    }
    return P[0][u];
  }
  int go_up(int u, int k) {
    for (int l : range(LOG)) {
      if (k & (1 << l)) {
        u = P[l][u];
      }
    }
    return u;
  }
  int dist(int u, int v) { return H[u] + H[v] - 2 * H[lca(u, v)]; }
  int solve(int u, int v) {
    if (u == v) {
      return graph.size();
    }
    int l = lca(u, v), du = H[u] - H[l], dv = H[v] - H[l], d = du + dv;
    if (d % 2) {
      return 0;
    }
    if (H[u] < H[v]) {
      swap(u, v);
      swap(du, dv);
    }
    int w = go_up(u, d / 2);
    if (du == dv) {
      return size[0] - size[go_up(u, du - 1)] - size[go_up(v, dv - 1)];
    } else {
      return size[w] - size[go_up(u, d / 2 - 1)];
    }
  }
  int brute(int u, int v) {
    int res = 0, n = graph.size();
    for (int i : range(n)) {
      if (dist(i, u) == dist(i, v)) {
        res++;
      }
    }
    return res;
  }
  vector<int> solve(const vector<pair<int, int>> &edges,
                    const vector<pair<int, int>> &queries) {
    int n = edges.size() + 1;
    graph.assign(n, {});
    size.resize(n);
    for (int i : range(1, n)) {
      int u, v;
      tie(u, v) = edges[i - 1];
      u--, v--;
      graph[u].push_back(v);
      graph[v].push_back(u);
    }
    P.assign(LOG, vector<int>(n));
    H.resize(n);
    init();
    int m = queries.size();
    vector<int> RES(m);
    for (int i : range(m)) {
      int x, y;
      tie(x, y) = queries[i];
      x--, y--;
      int res = solve(x, y);
      RES[i] = res;
    }
    return move(RES);
  }
  vector<int> brute(const vector<pair<int, int>> &edges,
                    const vector<pair<int, int>> &queries) {
    int m = queries.size();
    vector<int> res(m);
    for (int i : range(m)) {
      res[i] = brute(queries[i].first - 1, queries[i].second - 1);
    }
    return move(res);
  }

 public:
  void solve(std::istream &in, std::ostream &out) {
    int n;
    in >> n;
    vector<pair<int, int>> edges(n - 1);
    for (auto &ed : edges) {
      in >> ed.first >> ed.second;
    }
    int m;
    in >> m;
    vector<pair<int, int>> queries(m);
    for (auto &q : queries) {
      in >> q.first >> q.second;
    }
    vector<int> res = solve(edges, queries);
    for (int x : res) {
      out << x << "\n";
    }
  }
  const int N = 8;
  void setup() {}
};
int main() {
  std::ios_base::sync_with_stdio(false);
  EAAndBAndLectureRooms solver;
  solver.setup();
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  in.tie(nullptr);
  out << std::fixed;
  out.precision(20);
  solver.solve(in, out);
  return 0;
}
