#include <bits/stdc++.h>
using namespace std;
int dep[110000], n, m, f[110000][21], Log[110000], siz[110000];
inline int read() {
  int res = 0, flag = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') flag = -1;
    c = getchar();
  }
  while (isdigit(c)) res = (res << 3) + (res << 1) + c - '0', c = getchar();
  return res * flag;
}
int last[110000], p;
struct edge {
  int x, y, next;
  void Add_edge(int u, int v) {
    x = u;
    y = v;
    next = last[x];
    last[x] = p;
  }
} e[110000 * 2];
void dfs(int x, int fa) {
  f[x][0] = fa;
  dep[x] = dep[fa] + 1;
  siz[x] = 1;
  for (int j = 1; j <= Log[dep[x]]; j++) f[x][j] = f[f[x][j - 1]][j - 1];
  for (int k = last[x]; k; k = e[k].next) {
    int y = e[k].y;
    if (y == fa) continue;
    dfs(y, x);
    siz[x] += siz[y];
  }
}
int LCA(int u, int v) {
  if (dep[u] < dep[v]) swap(u, v);
  for (int j = Log[dep[u]]; j >= 0; j--)
    if (dep[f[u][j]] >= dep[v]) u = f[u][j];
  if (u == v) return u;
  for (int j = Log[dep[u]]; j >= 0; j--)
    if (f[u][j] != f[v][j]) u = f[u][j], v = f[v][j];
  return f[u][0];
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) Log[i] = Log[i / 2] + 1;
  for (int i = 1; i <= n - 1; i++) {
    int x = read(), y = read();
    e[++p].Add_edge(x, y);
    e[++p].Add_edge(y, x);
  }
  dfs(1, 0);
  m = read();
  while (m--) {
    int x = read(), y = read();
    if (x == y) {
      printf("%d\n", n);
      continue;
    }
    int lca = LCA(x, y);
    if (dep[x] < dep[y]) swap(x, y);
    int len = dep[x] + dep[y] - 2 * dep[lca];
    if (len & 1) {
      printf("0\n");
      continue;
    } else {
      if (dep[x] != dep[y]) {
        len /= 2;
        for (int j = Log[dep[x]]; j >= 0; j--)
          if (dep[x] - dep[f[x][j]] < len)
            len -= (dep[x] - dep[f[x][j]]), x = f[x][j];
        printf("%d\n", siz[f[x][0]] - siz[x]);
      } else {
        for (int j = Log[dep[x]]; j >= 0; j--)
          if (f[x][j] != f[y][j]) x = f[x][j], y = f[y][j];
        printf("%d\n", n - siz[x] - siz[y]);
      }
    }
  }
}
