#include <bits/stdc++.h>
using namespace std;
int len, n, m, size[1000000], wen[1000000], nex[1000000], hea[1000000],
    fa[100005][20], dep[1000000];
void add(int x, int y) {
  ++len;
  nex[len] = hea[x];
  wen[len] = y;
  hea[x] = len;
}
void dfs(int x, int y) {
  size[x] = 1;
  fa[x][0] = y;
  dep[x] = dep[y] + 1;
  for (int i = 1; i < 20; i++) fa[x][i] = fa[fa[x][i - 1]][i - 1];
  for (int i = hea[x]; i; i = nex[i])
    if (wen[i] != y) {
      dfs(wen[i], x);
      size[x] += size[wen[i]];
    }
}
int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 19; i >= 0; i--)
    if (dep[x] >= dep[y] + (1 << i)) x = fa[x][i];
  if (x == y) return x;
  for (int i = 19; i >= 0; i--)
    if (fa[x][i] != fa[y][i]) x = fa[x][i], y = fa[y][i];
  return fa[x][0];
}
int walk(int x, int y) {
  for (int i = 0; i <= 19; i++)
    if ((1 << i) & y) x = fa[x][i];
  return x;
}
int findson(int x, int y) {
  for (int i = 19; i >= 0; i--)
    if (dep[x] > dep[y] + (1 << i)) x = fa[x][i];
  return x;
}
int find(int x, int y) {
  int lca = LCA(x, y);
  if (dep[x] == dep[y])
    return n - (size[findson(x, lca)] + size[findson(y, lca)]);
  if ((dep[x] + dep[y] - dep[lca] * 2) % 2 == 1) return 0;
  int lenth = (dep[x] + dep[y] - dep[lca] * 2) >> 1;
  if (dep[x] < dep[y]) swap(x, y);
  int z = walk(x, lenth);
  return size[z] - size[findson(x, z)];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    add(x, y);
    add(y, x);
  }
  dfs(1, 0);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (x != y)
      printf("%d\n", find(x, y));
    else
      printf("%d\n", n);
  }
}
