#include <bits/stdc++.h>
using namespace std;
int inf = (1e9) + 7;
int mod = 998244353;
int visited[100005];
int tabela[100005][21];
int pai[100005];
int level[100005];
vector<int> graph[100005];
int filhos[100005];
int pot2[21];
int dfs2(int node) {
  if (visited[node]) return 0;
  visited[node] = 1;
  int aux = 1;
  for (auto u : graph[node]) {
    aux += dfs2(u);
  }
  filhos[node] = aux;
  return aux;
}
int f(int u, int i) {
  if (i == 0) {
    return pai[u];
  }
  if (tabela[u][i] != -1) return tabela[u][i];
  tabela[u][i] = f(f(u, i - 1), i - 1);
  return tabela[u][i];
}
void dfs(int u) {
  visited[u] = 1;
  for (auto v : graph[u]) {
    if (!visited[v]) {
      pai[v] = u;
      level[v] = level[u] + 1;
      dfs(v);
    }
  }
}
int lca(int u, int v) {
  if (level[u] < level[v]) swap(u, v);
  for (int i = 20; i >= 0; --i) {
    if (level[f(u, i)] >= level[v]) u = f(u, i);
  }
  if (u == v) return u;
  for (int i = 20; i >= 0; --i) {
    if (f(v, i) != f(u, i)) {
      v = f(v, i);
      u = f(u, i);
    }
  }
  return pai[v];
}
int dist(int u, int v) { return level[u] + level[v] - 2 * level[lca(u, v)]; }
int climb(int node, int quant) {
  if (quant == 0) return node;
  int i = 0;
  while (pot2[i] <= quant) i++;
  i--;
  return climb(f(node, i), quant - pot2[i]);
}
int main() {
  memset(tabela, -1, sizeof(tabela));
  for (int i = 0; i < 20; ++i) {
    pot2[i] = 1 << i;
  }
  int n;
  scanf("%d", &n);
  int a, b;
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  level[0] = 0;
  dfs(0);
  memset(visited, 0, sizeof(visited));
  dfs2(0);
  int q;
  scanf("%d", &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d %d", &a, &b);
    a--;
    b--;
    if (dist(a, b) & 1)
      printf("0\n");
    else {
      int l = lca(a, b);
      if (a == b)
        printf("%d\n", n);
      else if (level[a] == level[b]) {
        int fa = climb(a, -level[l] + level[a] - 1);
        int fb = climb(b, -level[l] + level[b] - 1);
        printf("%d\n", n - filhos[fa] - filhos[fb]);
      } else {
        if (level[a] > level[b]) swap(a, b);
        int fa = climb(b, (dist(a, b) / 2));
        int fb = climb(b, (dist(a, b) / 2) - 1);
        printf("%d\n", filhos[fa] - filhos[fb]);
      }
    }
  }
}
