#include <bits/stdc++.h>
using namespace std;
int DFS(vector<vector<int> >& P, vector<int>& L, vector<vector<int> >& sons,
        vector<int>& sum, int start, int level) {
  L[start] = level;
  int S = 1;
  for (int s : sons[start])
    if (L[s] < 0) {
      P[s][0] = start;
      S += DFS(P, L, sons, sum, s, level + 1);
    }
  sum[start] = S;
  return S;
}
int main() {
  int N;
  cin >> N;
  vector<vector<int> > sons(N + 1);
  vector<int> level(N + 1, -1);
  vector<int> sum(N + 1, 1);
  for (int i = 1; i < N; i++) {
    int a, b;
    cin >> a >> b;
    sons[a].push_back(b);
    sons[b].push_back(a);
  }
  int L2 = 0, n = 1;
  while (n < N) {
    L2++;
    n *= 2;
  }
  vector<vector<int> > P(N + 1, vector<int>(L2 + 1, 1));
  DFS(P, level, sons, sum, 1, 0);
  for (int i = 1; i <= L2; i++)
    for (int v = 1; v <= N; v++) P[v][i] = P[P[v][i - 1]][i - 1];
  int q;
  cin >> q;
  while (q--) {
    int A, B;
    cin >> A >> B;
    int a = A, b = B;
    int lca;
    if (a == b) {
      cout << N << "\n";
      continue;
    } else {
      if (level[a] < level[b]) {
        int diff = level[b] - level[a];
        for (int d = 0; d <= L2; d++)
          if ((1 << d) & diff) b = P[b][d];
      } else {
        int diff = level[a] - level[b];
        for (int d = 0; d <= L2; d++)
          if ((1 << d) & diff) a = P[a][d];
      }
      if (a == b)
        lca = a;
      else {
        while (P[a][0] != P[b][0]) {
          int M;
          for (M = 1; M <= L2; M++)
            if (P[a][M] == P[b][M]) break;
          M--;
          a = P[a][M];
          b = P[b][M];
        }
        lca = P[a][0];
      }
    }
    int dist = level[A] + level[B] - 2 * level[lca];
    if (dist % 2 == 1) {
      cout << 0 << "\n";
      continue;
    }
    dist /= 2;
    if (level[B] > level[A])
      A = B;
    else
      B = A;
    for (int d = 0; d <= L2; d++)
      if ((1 << d) & dist) A = P[A][d];
    int nu = 0;
    if (lca == A)
      nu += -sum[a] - sum[b] + N;
    else {
      for (int d = 0; d <= L2; d++)
        if ((1 << d) & (dist - 1)) B = P[B][d];
      nu += sum[A] - sum[B];
    }
    cout << nu << "\n";
  }
  return 0;
}
