#include <bits/stdc++.h>
using namespace std;
const int maxn = 100100;
struct edge {
  int Next, to;
};
edge G[200100];
int head[maxn], Deep[maxn], Anc[maxn][20], Size[maxn];
int N, M, Root, cnt = 2;
inline void Add_Edge(int u, int v) {
  G[cnt].to = v;
  G[cnt].Next = head[u];
  head[u] = cnt++;
  return;
}
void DFS_Init(int u, int fa) {
  Size[u] = 1;
  Anc[u][0] = fa;
  for (int i = 1; i < 20; ++i) Anc[u][i] = Anc[Anc[u][i - 1]][i - 1];
  for (int i = head[u]; i; i = G[i].Next) {
    int v = G[i].to;
    if (v == fa) continue;
    Deep[v] = Deep[u] + 1;
    DFS_Init(v, u);
    Size[u] += Size[v];
  }
  return;
}
int LCA(int u, int v) {
  if (u == Root || v == Root) return Root;
  if (Deep[u] < Deep[v]) swap(u, v);
  for (register int i = 19; i >= 0; --i) {
    if (Deep[Anc[u][i]] >= Deep[v]) u = Anc[u][i];
  }
  if (u == v) return u;
  for (register int i = 19; i >= 0; --i) {
    if (Anc[u][i] != Anc[v][i]) {
      u = Anc[u][i];
      v = Anc[v][i];
    }
  }
  return Anc[u][0];
}
int Calc(int u, int v) {
  int lca = LCA(u, v);
  int Len = Deep[u] - Deep[lca] + Deep[v] - Deep[lca];
  if (Deep[u] - Deep[lca] == Deep[v] - Deep[lca]) {
    int a = u;
    int b = v;
    for (register int i = 19; i >= 0; --i)
      if (Deep[u] - Deep[Anc[a][i]] <= Len / 2 - 1 &&
          Deep[Anc[a][i]] > Deep[lca])
        a = Anc[a][i];
    for (register int i = 19; i >= 0; --i)
      if (Deep[v] - Deep[Anc[b][i]] <= Len / 2 - 1 &&
          Deep[Anc[b][i]] > Deep[lca])
        b = Anc[b][i];
    int Res = N - Size[a] - Size[b];
    return Res;
  } else if (Deep[u] - Deep[lca] < Deep[v] - Deep[lca])
    swap(u, v);
  if (Len % 2 != 0) return 0;
  int temp = u;
  for (register int i = 19; i >= 0; --i)
    if (Deep[u] - Deep[Anc[temp][i]] <= Len / 2 &&
        Deep[Anc[temp][i]] > Deep[lca])
      temp = Anc[temp][i];
  int A = u;
  for (register int i = 19; i >= 0; --i)
    if (Deep[u] - Deep[Anc[A][i]] <= Len / 2 - 1 &&
        Deep[Anc[A][i]] > Deep[temp])
      A = Anc[A][i];
  int Res = Size[temp] - Size[A];
  return Res;
}
int main() {
  scanf("%d", &N);
  for (register int i = 1; i <= N - 1; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    Add_Edge(u, v);
    Add_Edge(v, u);
  }
  Root = 1;
  DFS_Init(Root, 0);
  scanf("%d", &M);
  for (int i = 1; i <= M; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    if (u == v)
      printf("%d\n", N);
    else
      printf("%d\n", Calc(u, v));
  }
  return 0;
}
