#include <bits/stdc++.h>
using namespace std;
int level[100005], children[100005], D[100005][20];
bool visited[100005];
vector<int> G[100005];
void DFS(int node, int l, int T) {
  level[node] = l;
  children[node] = 1;
  visited[node] = true;
  D[node][0] = T;
  for (int i = 1; i < 20; i++) {
    if (D[node][i - 1] == -1)
      D[node][i] = -1;
    else
      D[node][i] = D[D[node][i - 1]][i - 1];
  }
  for (int i = 0; i < G[node].size(); i++) {
    if (visited[G[node][i]]) continue;
    DFS(G[node][i], l + 1, node);
    children[node] += children[G[node][i]];
  }
}
int goUp(int x, int nr) {
  for (int i = 20 - 1; i >= 0; i--)
    if ((1 << i) <= nr) {
      x = D[x][i];
      nr -= (1 << i);
    }
  return x;
}
int LCA(int x, int y) {
  x = goUp(x, level[x] - level[y]);
  if (x == y) return x;
  for (int i = 20 - 1; i >= 0; i--)
    if (D[x][i] != -1 && D[x][i] != D[y][i]) {
      x = D[x][i];
      y = D[y][i];
    }
  return D[x][0];
}
int main() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    G[x].push_back(y);
    G[y].push_back(x);
  }
  DFS(1, 1, -1);
  int t;
  cin >> t;
  while (t--) {
    int x, y, dist;
    cin >> x >> y;
    if (level[x] < level[y]) {
      int aux = x;
      x = y;
      y = aux;
    }
    dist = level[x] + level[y] - 2 * level[LCA(x, y)];
    if (x == y) {
      cout << n << "\n";
      continue;
    }
    if (dist % 2 == 1) {
      cout << "0\n";
      continue;
    }
    if (level[x] == level[y]) {
      cout << n - children[goUp(x, dist / 2 - 1)] -
                  children[goUp(y, dist / 2 - 1)]
           << "\n";
    } else {
      cout << children[x, goUp(x, dist / 2)] -
                  children[x, goUp(x, dist / 2 - 1)]
           << "\n";
    }
  }
}
