#include <bits/stdc++.h>
using namespace std;
long long x, y, z, a, b, arr[100005][31], vis[100005], n1, n2, sz[100005];
deque<long long> q[100005];
long long dfs(long long s, long long ss) {
  vis[s] = vis[ss] + 1;
  arr[s][0] = ss;
  long long n = 1;
  for (auto i : q[s]) {
    if (i != ss) {
      n += dfs(i, s);
    }
  }
  sz[s] = n;
  return n;
}
long long indx(long long s, long long ss) {
  for (int i = 30; i >= 0; i--) {
    if ((ss >> i) & 1) {
      s = arr[s][i];
    }
  }
  return s;
}
long long lca(long long s, long long ss) {
  if (vis[s] < vis[ss]) {
    swap(s, ss);
  }
  n1 = sz[s], n2 = sz[ss];
  long long r = vis[s] - vis[ss];
  s = indx(s, r);
  if (s == ss) {
    return s;
  }
  for (int i = 30; i >= 0; i--) {
    if (arr[s][i] != arr[ss][i]) {
      s = arr[s][i];
      ss = arr[ss][i];
    }
  }
  n1 = sz[s], n2 = sz[ss];
  return arr[s][0];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  scanf("%lld", &x);
  for (int i = 0; i < x - 1; i++) {
    scanf("%d%d", &y, &z);
    q[y].push_back(z);
    q[z].push_back(y);
  }
  dfs(1, 0);
  for (int i = 1; i < 31; i++) {
    for (int j = 1; j <= x; j++) {
      arr[j][i] = arr[arr[j][i - 1]][i - 1];
    }
  }
  scanf("%lld", &y);
  for (int i = 0; i < y; i++) {
    scanf("%lld%lld", &a, &b);
    if (a == b) {
      printf("%lld\n", x);
      continue;
    }
    if (vis[a] < vis[b]) {
      swap(a, b);
    }
    long long s = lca(a, b);
    long long ans = abs(vis[a] - vis[s]) + abs(vis[b] - vis[s]);
    if (s == b) {
      ans = vis[a] - vis[b];
    }
    if (ans & 1) {
      printf("0\n");
    } else {
      long long r = indx(a, ans / 2), l = indx(a, ans / 2 - 1);
      if (s == r) {
        printf("%lld\n", x - n1 - n2);
      } else {
        printf("%d\n", sz[r] - sz[l]);
      }
    }
  }
  return 0;
}
