#include <bits/stdc++.h>
using namespace std;
const char InFile[] = "input.in";
const int MaxN = 100111;
const int LogMaxN = 18;
int N, M, x, y;
int up[MaxN][LogMaxN], niv[MaxN], viz[MaxN], w[MaxN];
vector<int> G[MaxN];
void DFS(int nod) {
  for (int i = 1; i < LogMaxN; ++i) {
    up[nod][i] = up[up[nod][i - 1]][i - 1];
  }
  w[nod] = 1;
  viz[nod] = 1;
  for (vector<int>::iterator it = G[nod].begin(); it != G[nod].end(); ++it) {
    if (!viz[*it]) {
      up[*it][0] = nod;
      niv[*it] = niv[nod] + 1;
      DFS(*it);
      w[nod] += w[*it];
    }
  }
}
int LCA(int x, int y) {
  if (x == y) {
    return x;
  }
  int step = LogMaxN - 1;
  while (niv[x] > niv[y]) {
    while (niv[up[x][step]] < niv[y]) {
      --step;
    }
    x = up[x][step];
  }
  while (niv[x] < niv[y]) {
    while (niv[up[y][step]] < niv[x]) {
      --step;
    }
    y = up[y][step];
  }
  if (x == y) {
    return x;
  }
  step = LogMaxN - 1;
  while (step >= 0) {
    if (up[x][step] != up[y][step]) {
      x = up[x][step];
      y = up[y][step];
    }
    --step;
  }
  while (x != y) {
    x = up[x][0];
    y = up[y][0];
  }
  return x;
}
int Dist(int x, int y, int l) { return niv[y] - niv[l] + niv[x] - niv[l]; }
int GetNod(int x, int d) {
  int step = LogMaxN - 1;
  int step_val = 1 << step;
  while (d) {
    if (step_val <= d) {
      d -= step_val;
      x = up[x][step];
    }
    step_val >>= 1;
    --step;
  }
  return x;
}
int main() {
  scanf("%d", &N);
  for (int i = 1; i < N; ++i) {
    scanf("%d %d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  DFS(1);
  scanf("%d", &M);
  for (int i = 1; i <= M; ++i) {
    scanf("%d %d", &x, &y);
    if (x == y) {
      printf("%d\n", N);
    } else {
      int l = LCA(x, y);
      int d = Dist(x, y, l);
      if (d % 2 == 1) {
        printf("0\n");
      } else {
        int sol = 1;
        d /= 2;
        if (x == l) {
          int nod = GetNod(y, d);
          int other_nod = GetNod(y, d - 1);
          sol = w[nod] - w[other_nod];
        } else if (y == l) {
          int nod = GetNod(x, d);
          int other_nod = GetNod(x, d - 1);
          sol = w[nod] - w[other_nod];
        } else {
          int dxl = niv[x] - niv[l];
          int dyl = niv[y] - niv[l];
          int nod = 0;
          int other_nod = 0;
          if (dxl >= d) {
            nod = GetNod(x, d);
            other_nod = GetNod(x, d - 1);
          } else {
            nod = GetNod(y, d);
            other_nod = GetNod(y, d - 1);
          }
          if (nod == l) {
            sol = N - w[GetNod(x, d - 1)] - w[GetNod(y, d - 1)];
          } else {
            sol = w[nod] - w[other_nod];
          }
        }
        printf("%d\n", sol);
      }
    }
  }
  return 0;
}
