#include <bits/stdc++.h>
using namespace std;
char buf[1 << 15], *p1 = buf, *p2 = buf;
template <class T>
inline bool read(T &x) {
  x = 0;
  bool w = 0;
  char ch = 0;
  while (!isdigit(ch) && ch != EOF)
    w |= ch == '-',
        ch = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 15, stdin),
                           p1 == p2)
                  ? EOF
                  : *p1++);
  if (ch == EOF) return 0;
  while (isdigit(ch))
    x = (x << 1) + (x << 3) + (ch ^ 48),
    ch =
        (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 15, stdin), p1 == p2)
             ? EOF
             : *p1++);
  x = w ? -x : x;
  return 1;
}
template <class T>
inline void write(T x) {
  if (!x) {
    puts("0");
    return;
  }
  if (x < 0) putchar('-'), x = -x;
  int num = 0;
  char ch[41];
  while (x) ch[++num] = x % 10 + 48, x /= 10;
  while (num) putchar(ch[num--]);
  puts("");
}
const int inf = 0x3f3f3f3f;
const int Maxn = 1e6 + 5;
int hd[Maxn], to[Maxn], nxt[Maxn], tot;
int n, m, fa[Maxn][20], dep[Maxn], siz[Maxn];
void add(int u, int v) {
  to[++tot] = v, nxt[tot] = hd[u], hd[u] = tot;
  to[++tot] = u, nxt[tot] = hd[v], hd[v] = tot;
}
void dfs(int u, int fr) {
  dep[u] = dep[fr] + 1, siz[u] = 1, fa[u][0] = fr;
  for (int i = 1; i <= 19; ++i) fa[u][i] = fa[fa[u][i - 1]][i - 1];
  for (int i = hd[u], v; i && (v = to[i]); i = nxt[i])
    if (v != fr) dfs(v, u), siz[u] += siz[v];
}
int LCA(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 19; i >= 0; --i)
    if (dep[fa[x][i]] >= dep[y]) 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 up(int x, int len) {
  int res = x;
  for (int i = 19; i >= 0; --i)
    if (dep[x] - dep[fa[res][i]] <= len) res = fa[res][i];
  return res;
}
int main(int argc, char const *argv[]) {
  read(n);
  for (int i = 1, u, v; i < n; ++i) read(u), read(v), add(u, v);
  dfs(1, 0);
  read(m);
  for (int i = 1, x, y; i <= m; ++i) {
    read(x), read(y);
    if (x == y) {
      write(siz[1]);
      continue;
    }
    int lca = LCA(x, y);
    int len = dep[x] + dep[y] - 2 * dep[lca] + 1;
    if (!(len & 1)) {
      puts("0");
      continue;
    }
    len /= 2;
    if (dep[x] - dep[lca] == len)
      write(siz[1] - siz[up(x, len - 1)] - siz[up(y, len - 1)]);
    else {
      if (dep[x] < dep[y]) swap(x, y);
      write(siz[up(x, len)] - siz[up(x, len - 1)]);
    }
  }
  return 0;
}
