#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100010];
int f[100010][20], depth[100010], n, dp[100010];
void dfs(int u) {
  for (int i = 1; i < 20; i++) f[u][i] = f[f[u][i - 1]][i - 1];
  int numChild = 0;
  for (int i = 0; i < (int)adj[u].size(); i++) {
    int v = adj[u][i];
    if (!depth[v]) {
      f[v][0] = u;
      depth[v] = depth[u] + 1;
      dfs(v);
      numChild += dp[v];
    }
  }
  dp[u] = numChild + 1;
}
int lca(int u, int v) {
  if (depth[u] < depth[v]) swap(u, v);
  for (int i = 20 - 1; i >= 0; i--)
    if (depth[f[u][i]] >= depth[v]) {
      u = f[u][i];
    }
  if (u == v) return u;
  for (int i = 20 - 1; i >= 0; i--)
    if (f[u][i] != f[v][i]) {
      u = f[u][i];
      v = f[v][i];
    }
  return f[u][0];
}
int dist(int u, int v) {
  int x = lca(u, v);
  int res = depth[u] + depth[v] - 2 * depth[x];
  return res;
}
int findKthParent(int src, int K) {
  int j = 0;
  while (K != 0) {
    if (K & 1) {
      src = f[src][j];
    }
    K /= 2;
    j++;
  }
  return src;
}
int main() {
  int n, i, j, k;
  scanf("%d", &n);
  for (i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d", &u);
    scanf("%d", &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  depth[1] = 1;
  dfs(1);
  int m;
  scanf("%d", &m);
  while (m--) {
    int x, y;
    scanf("%d", &x);
    scanf("%d", &y);
    int ans;
    if (x == y)
      ans = n;
    else {
      int LCA = lca(x, y);
      int D = depth[x] + depth[y] - 2 * depth[LCA];
      if (D % 2) {
        ans = 0;
      } else {
        int d = depth[x] - depth[LCA];
        if (depth[x] == depth[y]) {
          int p1 = findKthParent(x, d - 1);
          int p2 = findKthParent(y, d - 1);
          ans = n - dp[p1] - dp[p2];
        } else {
          if (depth[x] < depth[y]) swap(x, y);
          int p1 = findKthParent(x, D / 2 - 1);
          int p2 = f[p1][0];
          ans = dp[p2] - dp[p1];
        }
      }
    }
    printf("%d\n", ans);
  }
}
