#include <bits/stdc++.h>
using namespace std;
vector<int> g[100010];
int pa[100010][30];
int dep[100010], sz[100010];
int n;
int dfs(int i, int p, int d) {
  for (auto iter = g[i].begin(); iter != g[i].end(); iter++)
    if (*iter == p) {
      g[i].erase(iter);
      break;
    }
  pa[i][0] = p;
  dep[i] = d;
  sz[i] = 1;
  for (int j : g[i]) sz[i] += dfs(j, i, d + 1);
  return sz[i];
}
void preprocess() {
  for (int i = 1; i < 20; i++)
    for (int j = 1; j <= n; j++) pa[j][i] = pa[pa[j][i - 1]][i - 1];
}
int lca(int a, int b, int &la, int &lb) {
  if (a == b) {
    la = 0;
    lb = 0;
    return a;
  }
  bool sw = 0;
  if (dep[a] > dep[b]) {
    swap(a, b);
    sw = 1;
  }
  la = lb = 0;
  for (int i = 0; i < 20; i++)
    if ((dep[b] - dep[a]) >> i & 1) {
      b = pa[b][i];
      lb += 1 << i;
    }
  if (sw) swap(la, lb);
  if (a == b) return a;
  for (int i = 20; i >= 0; i--)
    if (pa[a][i] != pa[b][i]) {
      a = pa[a][i];
      b = pa[b][i];
      la += 1 << i;
      lb += 1 << i;
    }
  la++;
  lb++;
  return pa[a][0];
}
int up(int a, int mv) {
  for (int i = 0; i < 20; i++)
    if (mv >> i & 1) a = pa[a][i];
  return a;
}
int solve(int a, int b) {
  if (a == b) return n;
  int la, lb;
  int t = lca(a, b, la, lb);
  if ((la + lb) % 2 != 0) return 0;
  if (la > lb) {
    swap(la, lb);
    swap(a, b);
  }
  int mv = (la + lb) / 2;
  int mid = up(b, mv);
  if (t == mid) {
    return n - sz[up(b, mv - 1)] - sz[up(a, mv - 1)];
  } else {
    return sz[mid] - sz[up(b, mv - 1)];
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a, b;
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1, 1, 1);
  preprocess();
  int m;
  cin >> m;
  while (m--) {
    int a, b;
    cin >> a >> b;
    cout << solve(a, b) << '\n';
  }
}
