#include <bits/stdc++.h>
using namespace std;
long long int powm(long long int a, int b, int n) {
  long long int rm = 1;
  while (b) {
    if (b % 2) {
      rm = (rm * a) % n;
    }
    a = (a * a) % n;
    b /= 2;
  }
  return rm;
}
vector<int> edge[int(1e5 + 10)], dp[int(1e5 + 10)];
int L[int(1e5 + 10)], P[int(1e5 + 10)][20], T[int(1e5 + 10)],
    subsz[int(1e5 + 10)] = {0}, up[int(1e5 + 10)];
void process3(int n) {
  int i, j;
  memset(P, -1, sizeof(P));
  for (i = 1; i <= n; i++) P[i][0] = T[i];
  for (j = 1; (1 << j) <= n; j++) {
    for (i = 1; i <= n; i++) {
      if (P[i][j - 1] != -1) {
        P[i][j] = P[P[i][j - 1]][j - 1];
      }
    }
  }
}
int LCA(int p, int q) {
  if (p <= 0 || q <= 0) return 1;
  int tmp, log, i;
  if (L[p] < L[q]) {
    tmp = p, p = q, q = tmp;
  }
  for (log = 1; 1 << log <= L[p]; log++)
    ;
  log--;
  for (i = log; i >= 0; i--) {
    if (L[p] - (1 << i) >= L[q]) {
      p = P[p][i];
    }
    if (p == q) return p;
  }
  for (i = log; i >= 0; i--) {
    if (P[p][i] != -1 && P[p][i] != P[q][i]) {
      p = P[p][i], q = P[q][i];
    }
  }
  return T[p];
}
int ntot;
void dfs(int vertex, int parent, int depth) {
  L[vertex] = depth;
  T[vertex] = parent;
  subsz[vertex] = 1;
  for (int i = 0; i < edge[vertex].size(); ++i) {
    int vr = edge[vertex][i];
    if (vr != parent) {
      dfs(vr, vertex, depth + 1);
      dp[vertex][i] = subsz[vr];
      subsz[vertex] += subsz[vr];
    } else
      up[vertex] = i;
  }
  if (parent > 0) dp[vertex][up[vertex]] = ntot - subsz[vertex];
}
int LCA2(int v, int lca) {
  for (int i = 20; i >= 0; i--) {
    if (L[v] - (1 << i) > L[lca]) {
      v = P[v][i];
    }
  }
  return v;
}
int LCA3(int v, int dis) {
  for (int i = 20; i >= 0; i--) {
    if (dis >= (1 << i)) {
      v = P[v][i];
      dis -= 1 << i;
    }
  }
  return v;
}
int f(int vertex, int lca) {
  if (T[vertex] == lca) return subsz[vertex];
  int closestv = LCA2(vertex, lca);
  return subsz[closestv];
}
int main() {
  int n, u, v;
  cin >> n;
  ntot = n;
  for (int i = int(1); i <= (int)n - 1; i++) {
    scanf("%d", &u);
    ;
    scanf("%d", &v);
    ;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  for (int i = int(1); i <= (int)n; i++) dp[i].resize(edge[i].size() + 5);
  dfs(1, 0, 1);
  process3(n);
  int Q, a, b, lca, lca2, ans;
  cin >> Q;
  while (Q--) {
    scanf("%d", &a);
    ;
    scanf("%d", &b);
    ;
    if (a == b) {
      printf("%d\n", n);
      continue;
    }
    lca = LCA(a, b);
    int dis = L[a] - L[lca] + L[b] - L[lca];
    if (dis % 2) {
      printf("0\n");
    } else {
      if (L[a] == L[b]) {
        dis /= 2;
        ans = n - f(a, lca) - f(b, lca);
      } else {
        if (L[b] > L[a]) swap(a, b);
        lca2 = LCA3(a, dis / 2);
        int oo;
        if (lca2 == 1)
          oo = 0;
        else
          oo = dp[lca2][up[lca2]];
        ans = n - f(a, lca2) - oo;
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
