#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
const bool db = false;
int n, x, y, m;
vector<int> gr[100010];
int up[100010][19], ds[100010];
int sz[100010];
void dfs(int v, int pr) {
  up[v][0] = pr;
  sz[v] = 1;
  for (int i = 1; i < 18; ++i) {
    up[v][i] = up[up[v][i - 1]][i - 1];
  }
  for (int i = 0; i < gr[v].size(); ++i) {
    int to = gr[v][i];
    if (to == pr) continue;
    ds[to] = ds[v] + 1;
    dfs(to, v);
    sz[v] += sz[to];
  }
}
int calc(int v, int z) {
  for (int i = 17; i >= 0; --i) {
    if (z & (1 << i)) {
      v = up[v][i];
    }
  }
  return v;
}
int lca(int u, int v) {
  if (ds[u] > ds[v]) swap(u, v);
  int z = ds[v] - ds[u];
  for (int i = 17; i >= 0; --i) {
    if (z & (1 << i)) {
      v = up[v][i];
    }
  }
  for (int i = 17; i >= 0; --i) {
    if (up[v][i] != up[u][i]) {
      v = up[v][i];
      u = up[u][i];
    }
  }
  if (v != u) v = up[v][0];
  return v;
}
int f(int u, int v) {
  if (u == v) return n;
  int Lca = lca(u, v);
  int Len = ds[u] + ds[v] - 2 * ds[Lca];
  if (Len & 1) return 0;
  if (ds[u] - ds[Lca] == ds[v] - ds[Lca]) {
    int uu = calc(u, Len / 2 - 1);
    int vv = calc(v, Len / 2 - 1);
    return sz[1] - sz[uu] - sz[vv];
  }
  if (ds[u] - ds[Lca] > ds[v] - ds[Lca]) {
    swap(u, v);
  }
  int X = Len / 2;
  int md = calc(v, X);
  int md2 = calc(v, X - 1);
  return sz[md] - sz[md2];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    scanf("%d%d", &x, &y);
    gr[x].push_back(y);
    gr[y].push_back(x);
  }
  dfs(1, 1);
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    cout << f(x, y) << "\n";
  }
  getchar();
  getchar();
  return 0;
}
