#include <bits/stdc++.h>
using namespace std;
int n, m;
struct edge {
  int from;
  int to;
  int next;
} E[100005 << 1];
int head[100005];
int size = 0;
void add_edge(int u, int v) {
  size++;
  E[size].from = u;
  E[size].to = v;
  E[size].next = head[u];
  head[u] = size;
}
int log2n;
int cnt[100005];
int deep[100005];
int anc[100005][32];
void dfs(int x, int fa) {
  cnt[x] = 1;
  if (x != 1) deep[x] = deep[fa] + 1;
  anc[x][0] = fa;
  for (int i = 1; i <= log2n; i++) {
    anc[x][i] = anc[anc[x][i - 1]][i - 1];
  }
  for (int i = head[x]; i; i = E[i].next) {
    int y = E[i].to;
    if (y != fa) {
      dfs(y, x);
      cnt[x] += cnt[y];
    }
  }
}
int lca(int x, int y) {
  if (x == 1 || y == 1) return 1;
  if (deep[x] < deep[y]) swap(x, y);
  for (int i = log2n; i >= 0; i--) {
    if (deep[anc[x][i]] >= deep[y]) {
      x = anc[x][i];
    }
  }
  if (x == y) return x;
  for (int i = log2n; i >= 0; i--) {
    if (anc[x][i] != anc[y][i]) {
      x = anc[x][i];
      y = anc[y][i];
    }
  }
  return anc[x][0];
}
int get_mid(int x, int d) {
  for (int i = log2n; i >= 0; i--) {
    if (deep[anc[x][i]] >= d + 1) x = anc[x][i];
  }
  return x;
}
int get_ans(int x, int y) {
  if (x == y) return n;
  int dis = deep[x] + deep[y] - 2 * deep[lca(x, y)];
  if (deep[x] == deep[y]) {
    for (int i = log2n; i >= 0; i--) {
      if (anc[x][i] != anc[y][i]) {
        x = anc[x][i];
        y = anc[y][i];
      }
    }
    return n - cnt[x] - cnt[y];
  } else {
    if (dis % 2) return 0;
    if (deep[x] < deep[y]) swap(x, y);
    int mid = get_mid(x, deep[x] - dis / 2);
    return cnt[anc[mid][0]] - cnt[mid];
  }
}
int main() {
  int u, v;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &u, &v);
    add_edge(u, v);
    add_edge(v, u);
  }
  log2n = log2(n) + 1;
  deep[0] = 0;
  deep[1] = 1;
  dfs(1, 0);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &u, &v);
    printf("%d\n", get_ans(u, v));
  }
}
