#include <bits/stdc++.h>
using namespace std;
template <class t>
inline t read(t &x) {
  x = 0;
  char c = getchar();
  bool f = 0;
  while (!isdigit(c)) f |= c == '-', c = getchar();
  while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  if (f) x = -x;
  return x;
}
template <class t>
inline void write(t x) {
  if (x < 0) {
    putchar('-'), write(-x);
  } else {
    if (x > 9) write(x / 10);
    putchar('0' + x % 10);
  }
}
const int N = 1e5 + 5;
int en, h[N], n, q, S, d[N], dep[N], s[N], f[N][18], top[N], lim[N], rt, ans,
    sz[N];
vector<int> up[N], down[N];
struct edge {
  int n, v;
} e[N << 1];
void add(int x, int y) {
  e[++en] = (edge){h[x], y};
  h[x] = en;
}
void dfs1(int x) {
  dep[x] = d[x] = d[f[x][0]] + 1;
  sz[x] = 1;
  for (int i = h[x]; i; i = e[i].n) {
    int y = e[i].v;
    if (y == f[x][0]) continue;
    f[y][0] = x;
    for (int j = 0; f[y][j]; j++) f[y][j + 1] = f[f[y][j]][j];
    dfs1(y);
    sz[x] += sz[y];
    if (dep[y] > dep[x]) dep[x] = dep[y], s[x] = y;
  }
}
void dfs2(int x, int TOP) {
  top[x] = TOP;
  if (x == TOP) {
    for (int i = 0, pt = x; i <= dep[x] - d[x]; i++)
      up[x].push_back(pt), pt = f[pt][0];
    for (int i = 0, pt = x; i <= dep[x] - d[x]; i++)
      down[x].push_back(pt), pt = s[pt];
  }
  if (s[x]) dfs2(s[x], TOP);
  for (int i = h[x]; i; i = e[i].n) {
    int y = e[i].v;
    if (y == f[x][0]) continue;
    if (y ^ s[x]) dfs2(y, y);
  }
}
int kfa(int x, int k) {
  if (!k) return x;
  x = f[x][lim[k]];
  k -= 1 << lim[k];
  k -= d[x] - d[top[x]];
  x = top[x];
  if (k >= 0) return up[x][k];
  return down[x][-k];
}
int lca(int x, int y) {
  if (d[x] < d[y]) swap(x, y);
  for (int i = 17; i >= 0; i--)
    if (d[f[x][i]] >= d[y]) x = f[x][i];
  if (x == y) return x;
  for (int i = 17; i >= 0; i--)
    if (f[x][i] ^ f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
void doit() {
  int x, y;
  read(x);
  read(y);
  if (x == y) {
    write(n);
    puts("");
    return;
  }
  int LCA = lca(x, y);
  if (d[x] == d[y]) {
    write(n - sz[kfa(x, d[x] - d[LCA] - 1)] - sz[kfa(y, d[y] - d[LCA] - 1)]);
    puts("");
    return;
  }
  int dis = d[x] + d[y] - 2 * d[LCA];
  if (dis & 1) {
    puts("0");
    return;
  }
  dis >>= 1;
  int mid;
  if (d[x] > d[y]) {
    mid = kfa(x, dis);
    write(sz[mid] - sz[kfa(x, d[x] - d[mid] - 1)]);
  } else {
    mid = kfa(y, dis);
    write(sz[mid] - sz[kfa(y, d[y] - d[mid] - 1)]);
  }
  puts("");
}
signed main() {
  read(n);
  for (int i = 1, x, y; i < n; i++) {
    read(x);
    read(y);
    add(x, y);
    add(y, x);
  }
  lim[0] = -1;
  for (int i = 1; i <= n; i++) lim[i] = lim[i >> 1] + 1;
  dfs1(1);
  dfs2(1, 1);
  int t;
  read(t);
  while (t--) doit();
}
