#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e5 + 5, inf = 2e9;
vector<int> adj[nmax];
int now[nmax];
vector<int> seq;
int mini[nmax * 2][20], par[nmax][20], pos[nmax], depth[nmax], subsize[nmax],
    deg[nmax];
bool visited[nmax];
vector<int> leaves;
void build(int cur, int d) {
  depth[cur] = d;
  pos[cur] = seq.size();
  seq.push_back(d);
  bool leaf = true;
  while (now[cur] < adj[cur].size()) {
    int nxt = adj[cur][now[cur]];
    if (depth[nxt] == -1) {
      par[nxt][0] = cur;
      leaf = false;
      build(nxt, d + 1);
      seq.push_back(d);
    }
    now[cur]++;
  }
  if (leaf) leaves.push_back(cur);
}
int lca(int a, int b) {
  int l = pos[a], r = pos[b];
  if (l > r) swap(l, r);
  int s = r - l + 1;
  int p = 0;
  while ((1 << (p + 1)) <= s) p++;
  return min(mini[l][p], mini[r - (1 << p) + 1][p]);
}
int up(int a, int times) {
  for (int p = 19; p >= 0; --p) {
    if ((1 << p) <= times) {
      times -= 1 << p;
      a = par[a][p];
    }
  }
  return a;
}
int main() {
  for (int i = 0; i < nmax; ++i) {
    for (int j = 0; j < 20; ++j) {
      par[i][j] = -1;
      mini[i][j] = inf;
    }
    depth[i] = -1;
  }
  int n;
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    adj[a].push_back(b);
    adj[b].push_back(a);
    deg[a]++;
    deg[b]++;
  }
  build(1, 0);
  for (int i = 0; i < seq.size(); ++i) mini[i][0] = seq[i];
  for (int j = 1; j < 20; ++j) {
    for (int i = 0; i < seq.size(); ++i) {
      if (i + (1 << j) <= seq.size()) {
        mini[i][j] = min(mini[i][j - 1], mini[i + (1 << (j - 1))][j - 1]);
      }
    }
  }
  for (int j = 1; j < 20; ++j) {
    for (int i = 1; i <= n; ++i) {
      par[i][j] = par[par[i][j - 1]][j - 1];
    }
  }
  vector<int> topo;
  for (int i = 1; i <= n; ++i) {
    subsize[i] = 1;
  }
  for (int i = 0; i < leaves.size(); ++i) {
    int pos = leaves[i];
    if (visited[pos]) continue;
    visited[pos] = true;
    int nxt = par[pos][0];
    if (nxt != -1) {
      subsize[nxt] += subsize[pos];
      if (--deg[nxt] == 1) leaves.push_back(nxt);
    }
  }
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    int da = depth[a], db = depth[b], dm = lca(a, b);
    int dist = da - dm + db - dm;
    if (a == b) {
      cout << n << "\n";
      continue;
    }
    if (dist % 2 == 1) {
      cout << "0\n";
      continue;
    }
    {
      if (da < db) swap(a, b);
      int amid = up(a, dist / 2 - 1);
      int s = subsize[par[amid][0]] - subsize[amid];
      if (da == db) {
        int bmid = up(b, dist / 2 - 1);
        s = subsize[1] - subsize[amid] - subsize[bmid];
      }
      cout << s << '\n';
    }
  }
}
