#include <bits/stdc++.h>
using namespace std;
long long powmod(long long a, long long l, long long md) {
  a %= md;
  long long res = 1;
  while (l) {
    if (l & 1) res = res * a % md;
    l /= 2;
    a = a * a % md;
  }
  return res;
}
long long binpow(long long a, long long l) {
  long long res = 1;
  while (l) {
    if (l & 1) res = res * a;
    l /= 2;
    a = a * a;
  }
  return res;
}
long long invmod(long long a, long long md) { return powmod(a, md - 2, md); }
long long __set(long long b, long long i) { return b | (1LL << i); }
long long __unset(long long b, long long i) { return b & (~(1UL << i)); }
long long __check(long long b, long long i) { return b & (1LL << i); }
long long mulmod(long long a, long long b, long long md) {
  return (((a % md) * (b % md)) % md + md) % md;
}
long long addmod(long long a, long long b, long long md) {
  return ((a % md + b % md) % md + md) % md;
}
long long submod(long long a, long long b, long long md) {
  return (((a % md - b % md) % md) + md) % md;
}
long long divmod(long long a, long long b, long long md) {
  return mulmod(a, powmod(b, md - 2, md), md);
}
const long long inf = 0xFFFFFFFFFFFFFFFL;
priority_queue<long long, vector<long long>, greater<long long> > pq;
long long n;
vector<vector<long long> > g(100010);
struct AncestorK {
 public:
  long long n, m, depth, root, timer;
  vector<vector<long long> > g;
  vector<vector<long long> > table;
  vector<long long> dis, parent, tin, tout, sub;
  void dfs(long long u) {
    tin[u] = ++timer;
    for (long long v : g[u]) {
      if (dis[v] == -1) {
        dis[v] = dis[u] + 1;
        depth = max(depth, dis[v]);
        parent[v] = u;
        table[v][0] = u;
        dfs(v);
        sub[u] += sub[v];
      }
    }
    tout[u] = ++timer;
  }
  void compute() {
    dis[root] = 0;
    dfs(root);
    for (long long i = 0; i < m - 1; i++) {
      for (long long u = 0; u < n; u++) {
        long long v1 = table[u][i];
        if (v1 != -1) {
          v1 = table[v1][i];
          if (v1 != -1) table[u][i + 1] = v1;
        }
      }
    }
  }
  long long is_ancestor(long long u, long long v) {
    return tin[u] <= tin[v] && tout[u] >= tout[v];
  }
  AncestorK(vector<vector<long long> >& __g, long long __root = 0) {
    g = __g, root = __root, n = (long long)(g.size()),
    m = (long long)log2(n) + 1, depth = 0, timer = 0;
    dis.assign(n, -1);
    parent.assign(n, -1);
    tin.assign(n, 0);
    tout.assign(n, 0);
    sub.assign(n, 1);
    for (long long i = 0; i < n; i++) {
      vector<long long> tp(m, -1);
      table.push_back(tp);
    }
    compute();
  }
  long long kth_ancestor(long long u, long long k) {
    if (dis[u] < k) return -1;
    if (k == 0) return u;
    long long c = u;
    for (long long bit = 0; bit < m; ++bit) {
      if (c == -1) return -1;
      if ((k & (1ll << bit))) c = table[c][bit];
    }
    return c;
  }
  long long lca(long long u, long long v) {
    if (is_ancestor(u, v)) return u;
    if (is_ancestor(v, u)) return v;
    for (long long i = m - 1; i >= 0; --i) {
      if (table[u][i] == -1) continue;
      if (!is_ancestor(table[u][i], v)) u = table[u][i];
    }
    return table[u][0];
  }
};
signed main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  for (long long i = 0; i < n - 1; i++) {
    long long u, v;
    cin >> u >> v;
    g[u - 1].push_back(v - 1);
    g[v - 1].push_back(u - 1);
  }
  AncestorK lc(g);
  long long q;
  cin >> q;
  while (q--) {
    long long x, y;
    cin >> x >> y;
    x--;
    y--;
    long long l = lc.lca(x, y);
    if (x == y) {
      cout << n << "\n";
      continue;
    }
    if (lc.dis[x] == lc.dis[y]) {
      long long vx = lc.kth_ancestor(x, lc.dis[x] - lc.dis[l] - 1),
                vy = lc.kth_ancestor(y, lc.dis[y] - lc.dis[l] - 1);
      cout << n - lc.sub[vx] - lc.sub[vy] << "\n";
    } else {
      long long d = lc.dis[x] - lc.dis[l] + lc.dis[y] - lc.dis[l];
      if (d % 2) {
        cout << 0 << "\n";
        continue;
      }
      if (lc.dis[x] > lc.dis[y]) {
        long long pt = lc.kth_ancestor(x, d / 2);
        long long ux = lc.kth_ancestor(x, d / 2 - 1);
        cout << lc.sub[pt] - lc.sub[ux] << "\n";
      } else {
        long long pt = lc.kth_ancestor(y, d / 2);
        long long uy = lc.kth_ancestor(y, d / 2 - 1);
        cout << lc.sub[pt] - lc.sub[uy] << "\n";
      }
    }
  }
  return 0;
}
