#include <bits/stdc++.h>
using namespace std;
long long mexp(long long a, long long b) {
  long long ans = 1;
  a %= 1000000007;
  while (b) {
    if (b & 1) ans = ans * a % 1000000007;
    b >>= 1;
    a = a * a % 1000000007;
  }
  return ans;
}
const int N = 100005;
const int LG = 18;
int n, m;
vector<long long> g[N];
int depth[N], anc[N][LG];
int in[N], out[N], siz[N];
int tim = 0;
void dfs(int u, int p, int d) {
  tim++;
  in[u] = tim;
  siz[u] = 1;
  depth[u] = d;
  anc[u][0] = p;
  for (long long i = 1; i < LG; ++i) {
    anc[u][i] = anc[anc[u][i - 1]][i - 1];
  }
  for (int v : g[u]) {
    if (v != p) {
      dfs(v, u, d + 1);
      siz[u] += siz[v];
    }
  }
  tim++;
  out[u] = tim;
}
bool isanc(int u, int v) {
  if (in[u] <= in[v] && out[u] >= out[v]) {
    return 1;
  }
  return 0;
}
int ubchild(int u, int v) {
  for (long long i = LG - 1; i >= 0; --i) {
    if (!isanc(anc[u][i], v)) {
      u = anc[u][i];
    }
  }
  return u;
}
int getLCA(int u, int v) {
  if (depth[u] < depth[v]) {
    swap(u, v);
  }
  int log;
  for (log = 1; (1 << log) <= depth[u]; log++)
    ;
  log--;
  for (long long i = log; i >= 0; --i) {
    if (depth[u] - depth[v] >= (1 << i)) {
      u = anc[u][i];
    }
  }
  if (u == v) {
    return u;
  }
  for (long long i = log; i >= 0; --i) {
    if (anc[u][i] != -1 && anc[u][i] != anc[v][i]) {
      u = anc[u][i];
      v = anc[v][i];
    }
  }
  return anc[u][0];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (long long i = 0; i < N; ++i) {
    for (long long j = 0; j < LG; ++j) {
      anc[i][j] = -1;
    }
  }
  cin >> n;
  for (long long i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1, 1, 0);
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    if (a == b) {
      cout << n << endl;
      continue;
    }
    int lca = getLCA(a, b);
    if (depth[a] - depth[lca] == depth[b] - depth[lca]) {
      a = ubchild(a, lca);
      b = ubchild(b, lca);
      cout << n - siz[a] - siz[b] << endl;
      continue;
    }
    int dist = (depth[a] - depth[lca]) + (depth[b] - depth[lca]);
    if (dist % 2 == 1) {
      cout << 0 << endl;
    } else {
      if (depth[a] < depth[b]) {
        swap(a, b);
      }
      dist /= 2;
      int temp = a;
      for (long long i = LG - 1; i >= 0; --i) {
        if (depth[a] - depth[anc[temp][i]] < dist) {
          temp = anc[temp][i];
        }
      }
      int p = anc[temp][0];
      cout << siz[p] - siz[temp] << endl;
      cerr << p << " " << a << endl;
    }
  }
  cerr << "Time: " << 1.0 / CLOCKS_PER_SEC << " ms" << endl;
  return 0;
}
