#include <bits/stdc++.h>
using namespace std;
struct IO {
  char buf[(1 << 20)], *p1, *p2;
  char pbuf[(1 << 20)], *pp;
  IO() : p1(buf), p2(buf), pp(pbuf) {}
  inline char gc() {
    return getchar();
    if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, (1 << 20), stdin);
    return p1 == p2 ? ' ' : *p1++;
  }
  inline bool blank(char ch) {
    return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
  }
  template <class T>
  inline void read(T &x) {
    register double tmp = 1;
    register bool sign = 0;
    x = 0;
    register char ch = gc();
    for (; !(ch >= '0' && ch <= '9'); ch = gc())
      if (ch == '-') sign = 1;
    for (; (ch >= '0' && ch <= '9'); ch = gc()) x = x * 10 + (ch - '0');
    if (ch == '.')
      for (ch = gc(); (ch >= '0' && ch <= '9'); ch = gc())
        tmp /= 10.0, x += tmp * (ch - '0');
    if (sign) x = -x;
  }
  inline void read(char *s) {
    register char ch = gc();
    for (; blank(ch); ch = gc())
      ;
    for (; !blank(ch); ch = gc()) *s++ = ch;
    *s = 0;
  }
  inline void read(char &c) {
    for (c = gc(); blank(c); c = gc())
      ;
  }
  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);
    }
  }
} io;
const int mod = 1e9 + 7;
const int mo = 998244353;
const int N = 2e5 + 5;
int n, m, Q, cnt, dep[N], siz[N], f[N][21], head[N];
struct Node {
  int nex, to;
};
Node e[N << 1];
inline void jia(int u, int v) {
  e[++cnt].nex = head[u];
  head[u] = cnt;
  e[cnt].to = v;
}
inline void dfs(int u, int fa) {
  dep[u] = dep[fa] + 1;
  f[u][0] = fa;
  siz[u] = 1;
  for (int i = (1); i <= (19); i++) f[u][i] = f[f[u][i - 1]][i - 1];
  for (int i = head[u]; i; i = e[i].nex) {
    int v = e[i].to;
    if (v == fa) continue;
    dfs(v, u);
    siz[u] += siz[v];
  }
}
inline int LCA(int x, int y) {
  if (dep[x] > dep[y]) swap(x, y);
  for (int i = (19); i >= (0); i--)
    if (dep[y] - (1 << i) >= dep[x]) y = f[y][i];
  if (x == y) return x;
  for (int i = (19); i >= (0); i--)
    if (f[x][i] ^ f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
int main() {
  io.read(n);
  for (int i = (1); i <= (n - 1); i++) {
    int x, y;
    io.read(x), io.read(y);
    jia(x, y), jia(y, x);
  }
  dfs(1, 0);
  io.read(Q);
  for (; Q--;) {
    int x, y;
    io.read(x), io.read(y);
    if (dep[x] == dep[y]) {
      if (x == y) {
        io.write(n), puts("");
        continue;
      }
      int z = LCA(x, y);
      int dx = dep[x] - dep[z] - 1;
      for (int i = (19); i >= (0); i--)
        if ((dx >> i) & 1) x = f[x][i];
      dx = dep[y] - dep[z] - 1;
      for (int i = (19); i >= (0); i--)
        if ((dx >> i) & 1) y = f[y][i];
      io.write(n - siz[x] - siz[y]), puts("");
      continue;
    }
    int z = LCA(x, y);
    int len = dep[x] + dep[y] - 2 * dep[z];
    if (len & 1) {
      puts("0");
      continue;
    }
    len >>= 1;
    if (dep[x] < dep[y]) swap(x, y);
    int w = x;
    for (int i = (19); i >= (0); i--)
      if ((len >> i) & 1) w = f[w][i];
    int tx = x, dx = dep[x] - dep[w] - 1;
    for (int i = (19); i >= (0); i--)
      if ((dx >> i) & 1) tx = f[tx][i];
    io.write(siz[w] - siz[tx]), puts("");
  }
  return 0;
}
