#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n, p[N][20], i, j, level[N], pa[N], q, k, siz[N];
vector<int> adj[N];
bool vis[N];
template <typename T>
inline void Cin(T& x) {
  char c = getchar();
  x = 0;
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
}
template <typename T, typename... Args>
inline void Cin(T& a, Args&... args) {
  Cin(a);
  Cin(args...);
}
void dfs(int x) {
  vis[x] = true;
  for (auto& u : adj[x]) {
    if (!vis[u]) {
      pa[u] = x;
      level[u] = level[x] + 1;
      dfs(u);
      siz[x] += siz[u];
    }
  }
}
int LCA(int x, int y) {
  int diff = abs(level[y] - level[x]);
  if (level[x] < level[y]) {
    for (k = 20; k >= 0; k--) {
      if (diff >> k & 1 == 1) y = p[y][k];
    }
  } else if (level[x] > level[y]) {
    for (k = 20; k >= 0; k--) {
      if (diff >> k & 1 == 1) x = p[x][k];
    }
  }
  if (x == y) return x;
  if (x == 1 || y == 1) return x;
  for (int k = 16; k >= 0; k--) {
    if (p[x][k] != p[y][k]) {
      x = p[x][k];
      y = p[y][k];
    }
  }
  return p[x][0];
}
int Find(int x, int diff) {
  for (k = 20; k >= 0; k--) {
    if (diff >> k & 1 == 1) x = p[x][k];
  }
  return x;
}
int main() {
  fill(begin(siz), end(siz), 1);
  Cin(n);
  for (i = 1; i < n; i++) {
    int u, v;
    Cin(u, v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  level[1] = 0;
  dfs(1);
  for (int k = 0; (1 << k) <= n; k++) {
    for (i = 2; i <= n; i++) {
      if (k == 0)
        p[i][k] = pa[i];
      else
        p[i][k] = p[p[i][k - 1]][k - 1];
    }
  }
  Cin(q);
  while (q--) {
    int x, y;
    Cin(x, y);
    if (x == y) {
      cout << n << '\n';
      continue;
    }
    int lca = LCA(x, y);
    int disx = level[x] - level[lca];
    int disy = level[y] - level[lca];
    int dis = disx + disy;
    if (dis % 2 != 0) {
      cout << 0 << '\n';
      continue;
    }
    if (disx == disy) {
      int far = disx - 1;
      cout << n - siz[Find(x, far)] - siz[Find(y, far)] << '\n';
    } else if (disx > disy) {
      int th = dis / 2;
      int Parent = Find(x, th);
      int Parent_1 = Find(x, th - 1);
      cout << siz[Parent] - siz[Parent_1] << '\n';
    } else if (disx < disy) {
      int th = dis / 2;
      int Parent = Find(y, th);
      int Parent_1 = Find(y, th - 1);
      cout << siz[Parent] - siz[Parent_1] << '\n';
    }
  }
}
