#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int> > gr;
int an[100010][20], tin[100010], tout[100010], t;
int dep[100010], sz[100010];
void dfs(int x, int par, int d) {
  tin[x] = t++;
  dep[x] = d;
  sz[x] = 1;
  an[x][0] = par;
  for (int i = 1; i < 20; ++i) {
    an[x][i] = an[an[x][i - 1]][i - 1];
  }
  for (auto i : gr[x]) {
    if (i != par) {
      dfs(i, x, d + 1);
      sz[x] += sz[i];
    }
  }
  tout[x] = t++;
}
bool isyananc(int x, int y) {
  return (tin[y] <= tin[x] and tout[y] >= tout[x]);
}
int lca(int x, int y) {
  if (isyananc(x, y)) {
    return y;
  }
  if (isyananc(y, x)) {
    return x;
  }
  for (int i = 20 - 1; i >= 0; --i) {
    if (!isyananc(x, an[y][i])) {
      y = an[y][i];
    }
  }
  y = an[y][0];
  return y;
}
int kthanc(int k, int x) {
  int i = 0;
  while (k) {
    if (k & 1) {
      x = an[x][i];
    }
    k >>= 1;
    ++i;
  }
  return x;
}
int sol(int x, int y) {
  if (x == y) {
    return n;
  }
  int l = lca(x, y);
  int d = dep[x] - dep[l] + dep[y] - dep[l];
  if (d & 1) {
    return 0;
  }
  if (d == 2 * (dep[x] - dep[l])) {
    for (int i = 20 - 1; i >= 0; --i) {
      if (!isyananc(l, an[x][i])) {
        x = an[x][i];
      }
      if (!isyananc(l, an[y][i])) {
        y = an[y][i];
      }
    }
    return n - sz[x] - sz[y];
  }
  if (dep[x] < dep[y]) {
    swap(x, y);
  }
  return sz[kthanc(d / 2, x)] - sz[kthanc(d / 2 - 1, x)];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  vector<int> vi;
  gr.resize(n + 1, vi);
  for (int i = 1; i < n; ++i) {
    int u, v;
    cin >> u >> v;
    gr[u].push_back(v);
    gr[v].push_back(u);
  }
  cin >> m;
  dfs(1, 1, 0);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    cout << sol(x, y) << '\n';
  }
}
