#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
const int mx = 1e5 + 123;
int p[mx][30], level[mx], sz[mx], parent[mx];
vector<int> adj[mx];
int dfs_for_LCA(int u, int lev) {
  sz[u] = 1;
  level[u] = lev;
  for (auto v : adj[u]) {
    if (v != parent[u]) {
      parent[v] = u;
      sz[u] += dfs_for_LCA(v, lev + 1);
    }
  }
  return sz[u];
}
void preprocess(int n) {
  memset(p, -1, sizeof(p));
  for (int i = 1; i <= n; i++) p[i][0] = parent[i];
  for (int i = 1; (1 << i) <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (p[j][i - 1] != -1) p[j][i] = p[p[j][i - 1]][i - 1];
    }
  }
}
int up(int u, int dist) {
  while (dist > 0) {
    int rise = log2(dist);
    u = p[u][rise];
    dist -= (1 << rise);
  }
  return u;
}
int LCA(int u, int v) {
  if (level[u] < level[v]) swap(u, v);
  int dist = level[u] - level[v];
  u = up(u, dist);
  if (u == v) return u;
  for (int i = 20; i >= 0; i--) {
    if (p[u][i] != p[v][i] && p[u][i] != -1) {
      u = p[u][i];
      v = p[v][i];
    }
  }
  return parent[u];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int n, u, v, m;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs_for_LCA(1, 0);
  preprocess(n);
  cin >> m;
  while (m--) {
    cin >> u >> v;
    int lca = LCA(u, v);
    int dist_u = level[u] - level[lca] - 1;
    int dist_v = level[v] - level[lca] - 1;
    if (u == v)
      cout << n << endl;
    else if ((dist_u + dist_v) % 2)
      cout << 0 << endl;
    else if (level[u] == level[v]) {
      u = up(u, dist_u);
      v = up(v, dist_v);
      cout << n - sz[u] - sz[v] << endl;
    } else {
      if (level[u] < level[v]) {
        swap(u, v);
      }
      int dist = (dist_u + dist_v + 2) >> 1;
      v = up(u, dist - 1);
      u = up(u, dist);
      cout << sz[u] - sz[v] << endl;
    }
  }
  return 0;
}
