#include <bits/stdc++.h>
using namespace std;
const int E[] = {1, 2, 4, 8, 16};
int P[100005], C[100005], L[100005], M[100005][17];
vector<int> A[100005];
int DFS(int u, int parent, int level) {
  P[u] = parent, L[u] = level, C[u] = 1;
  for (vector<int>::iterator p = A[u].begin(); p != A[u].end(); ++p)
    if (*p != parent) C[u] += DFS(*p, u, level + 1);
  return C[u];
}
int floor_log(int n) {
  int lg = 0, i;
  for (i = 4; i >= 0; --i)
    if (n >= (1 << E[i])) lg |= E[i], n >>= E[i];
  return lg;
}
void DP(int n) {
  int i, j, lg = floor_log(n - 1);
  for (i = 1; i <= n; ++i) {
    M[i][0] = P[i];
    for (j = 1; j <= lg; ++j) M[i][j] = -1;
  }
  for (j = 1; j <= lg; ++j)
    for (i = 1; i <= n; ++i)
      if (M[i][j - 1] != -1) M[i][j] = M[M[i][j - 1]][j - 1];
}
int LCA(int u, int v, int &u1, int &v1) {
  int lg, i;
  if (L[u] < L[v]) swap(u, v);
  lg = floor_log(L[u]);
  for (i = lg; i >= 0; --i)
    if (L[u] - (1 << i) >= L[v]) u = M[u][i];
  if (u == v) return u;
  lg = floor_log(L[u]);
  for (i = lg; i >= 0; --i)
    if (M[u][i] != -1 && M[u][i] != M[v][i]) u = M[u][i], v = M[v][i];
  u1 = u, v1 = v;
  return P[u];
}
int mid_path(int u, int v, int lca, int &u1) {
  int d1, d2, midLevel, lg, i;
  if (L[u] < L[v]) swap(u, v);
  d1 = L[u] - L[lca], d2 = L[v] - L[lca];
  midLevel = L[lca] + (d1 + d2) / 2 - d2;
  lg = floor_log(L[u]);
  for (i = lg; i >= 0; --i)
    if (L[u] - (1 << i) > midLevel) u = M[u][i];
  u1 = u;
  return P[u];
}
void solve(int n, int q) {
  int u, v, u1, v1, w, lca;
  DFS(1, -1, 0);
  DP(n);
  while (q--) {
    scanf("%d %d", &u, &v);
    if (u == v)
      printf("%d\n", n);
    else {
      lca = LCA(u, v, u1, v1);
      if ((L[u] + L[v] - 2 * L[lca]) & 1)
        puts("0");
      else if (L[u] == L[v])
        printf("%d\n", n - C[u1] - C[v1]);
      else {
        w = mid_path(u, v, lca, u1);
        printf("%d\n", C[w] - C[u1]);
      }
    }
  }
}
int main() {
  int n, m, u, v, i;
  scanf("%d", &n);
  for (i = 1; i < n; ++i) {
    scanf("%d %d", &u, &v);
    A[u].push_back(v), A[v].push_back(u);
  }
  scanf("%d", &m);
  solve(n, m);
  return 0;
}
