#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
const int N = 100010;
const int M = 18;
vector<long long> g[N];
int n;
int dis[N], tr[N], lca[M][N];
void dfs(int x, int ult = 0, int prof = 0) {
  lca[0][x] = ult;
  tr[x] = 1;
  dis[x] = prof;
  for (int i = 0; i < g[x].size(); ++i) {
    int y = g[x][i];
    if (y == ult) continue;
    dfs(y, x, prof + 1);
    tr[x] += tr[y];
  }
}
void build() {
  for (int i = 1; i < M; ++i)
    for (int j = 1; j <= n; ++j) lca[i][j] = lca[i - 1][lca[i - 1][j]];
}
int anc(int a, int b) {
  int d = dis[a] - dis[b];
  for (int i = 0; i < M; ++i)
    if (d & (1 << i)) a = lca[i][a];
  if (a - b == 0) return a;
  for (int i = M - 1; i >= 0; --i)
    if (lca[i][a] != lca[i][b]) a = lca[i][a], b = lca[i][b];
  return lca[0][a];
}
int go_up(int a, int x) {
  for (int i = M - 1; i >= 0; --i)
    if (x >= (1 << i)) a = lca[i][a], x -= (1 << i);
  return a;
}
int solve(int a, int b) {
  if (a == b) return n;
  if (dis[a] < dis[b]) swap(a, b);
  int l = anc(a, b);
  int w = dis[a] + dis[b] - 2 * dis[l];
  if (w & 1) return 0;
  w /= 2;
  if (dis[a] == dis[b]) {
    int aa = go_up(a, w - 1);
    int bb = go_up(b, w - 1);
    return n - tr[aa] - tr[bb];
  } else {
    int c = go_up(a, w);
    int z = go_up(a, w - 1);
    return tr[c] - tr[z];
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1);
  build();
  int q;
  scanf("%d", &q);
  while (q--) {
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\n", solve(a, b));
  }
  return 0;
}
