#include <bits/stdc++.h>
using std::memset;
using std::swap;
FILE *fin, *fout;
inline int read() {
  int x = 0, f = 1;
  char c = fgetc(fin);
  for (; (c < '0' || c > '9'); c = fgetc(fin)) {
    if (c == EOF) {
      return x * f;
    }
    if (c == '-') {
      f = -f;
    }
  }
  for (; !(c < '0' || c > '9'); c = fgetc(fin)) {
    x = (x << 3) + (x << 1) + (c ^ '0');
  }
  return x * f;
}
const int maxn = 1000100;
int n, m;
struct graph {
  int tot, head[maxn];
  int next[maxn << 1], val[maxn << 1];
  graph() {
    tot = 0;
    memset(head, 0, sizeof(head));
  }
  void addEdge(int u, int v) {
    val[++tot] = v;
    next[tot] = head[u];
    head[u] = tot;
  }
} g;
int _log[maxn];
void _log_setup() {
  _log[0] = -1;
  _log[1] = 0;
  for (int i = 2; i < maxn; ++i) {
    _log[i] = _log[i >> 1] + 1;
  }
}
int depth[maxn];
int tsize[maxn];
int f[maxn][20];
void lca_setup(int fa, int p) {
  tsize[p] = 1;
  depth[p] = ((fa != 0) ? (depth[fa] + 1) : 0);
  f[p][0] = fa;
  for (int t = 1; t <= _log[depth[p]]; ++t) {
    f[p][t] = f[f[p][t - 1]][t - 1];
  }
  for (int i = g.head[p]; i != 0; i = g.next[i]) {
    int np = g.val[i];
    if (tsize[np] == 0) {
      lca_setup(p, np);
      tsize[p] += tsize[np];
    }
  }
}
int up(int p, int k) {
  for (int t = 0; k > 0; ++t, k = k >> 1) {
    if (k & 1) {
      p = f[p][t];
    }
  }
  return p;
}
int lca(int a, int b) {
  if (depth[a] > depth[b]) {
    swap(a, b);
  }
  b = up(b, depth[b] - depth[a]);
  if (a == b) {
    return a;
  }
  for (int t = _log[depth[a]]; t >= 0;) {
    if (f[a][t] != f[b][t]) {
      a = f[a][t];
      b = f[b][t];
      t = _log[depth[a]];
    } else {
      --t;
    }
  }
  return f[a][0];
}
signed main() {
  fin = stdin;
  fout = stdout;
  n = read();
  int u, v;
  for (int i = 1; i < n; ++i) {
    u = read();
    v = read();
    g.addEdge(u, v);
    g.addEdge(v, u);
  }
  _log_setup();
  int root = 1;
  lca_setup(0, root);
  m = read();
  int a, b, c, d, x;
  int ans;
  for (int tm = 1; tm <= m; ++tm) {
    a = read();
    b = read();
    x = lca(a, b);
    if (a == b) {
      ans = n;
    } else if (depth[a] == depth[b]) {
      c = up(a, depth[a] - depth[x] - 1);
      d = up(b, depth[b] - depth[x] - 1);
      ans = tsize[root] - tsize[c] - tsize[d];
    } else if ((depth[a] + depth[b]) % 2 != 0) {
      ans = 0;
    } else if (x == a || x == b) {
      if (x == b) {
        swap(a, b);
      }
      int dep = (depth[b] - depth[a]) >> 1;
      d = up(b, dep - 1);
      c = up(d, 1);
      ans = tsize[c] - tsize[d];
    } else {
      if (depth[a] > depth[b]) {
        swap(a, b);
      }
      int da = depth[a] - depth[x];
      int db = depth[b] - depth[x];
      int dep = (da + db) >> 1;
      d = up(b, dep - 1);
      c = up(d, 1);
      ans = tsize[c] - tsize[d];
    }
    fprintf(fout, "%d\n", ans);
  }
  return 0;
}
