#include <bits/stdc++.h>
using namespace std;
const int mxN = 1e5;
const int lvl = 20;
int n, m;
vector<int> adj[mxN];
int prnt[mxN][lvl + 1];
int dpt[mxN];
int sub[mxN];
int dfs(int u, int e, int d) {
  prnt[u][0] = e;
  dpt[u] = d;
  for (int i = 1; i <= lvl; i++)
    if (prnt[u][i - 1] != -1) prnt[u][i] = prnt[prnt[u][i - 1]][i - 1];
  int ret = 1;
  for (auto ad = adj[u].begin(); ad != adj[u].end(); ad++) {
    if (*ad == e) continue;
    ret += dfs(*ad, u, d + 1);
  }
  sub[u] = ret;
  return ret;
}
int dist(int u, int v) {
  if (dpt[u] < dpt[v]) swap(u, v);
  int dist = 0;
  for (int i = lvl; i >= 0; i--) {
    if (dpt[u] - dpt[v] >= (1 << i)) {
      dist += 1 << i;
      u = prnt[u][i];
    }
  }
  while (dpt[u] != dpt[v]) {
    cout << "ERROR" << endl;
  }
  if (u == v) return dist;
  for (int i = lvl; i >= 0; i--) {
    if (prnt[u][i] != -1 && prnt[u][i] != prnt[v][i] && prnt[v][i] != -1) {
      dist += 1 << (i + 1);
      u = prnt[u][i];
      v = prnt[v][i];
    }
  }
  return dist + 2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  memset(prnt, -1, lvl * mxN * 4);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  cin >> m;
  dfs(0, -1, 0);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    if (x == y) {
      cout << n << endl;
      continue;
    }
    int di = dist(x, y);
    if (di & 1) {
      cout << 0 << endl;
      continue;
    }
    if (dpt[x] < dpt[y]) swap(x, y);
    di /= 2;
    di--;
    bool meetlca = 1;
    for (int i = lvl; i >= 0; i--) {
      if (di >= (1 << i)) {
        di -= (1 << i);
        x = prnt[x][i];
        if (prnt[y][i] != -1) {
          y = prnt[y][i];
        } else {
          meetlca = 0;
        }
      }
    }
    if (prnt[x][0] != prnt[y][0] || meetlca == false) {
      cout << sub[prnt[x][0]] - sub[x] << endl;
    } else {
      cout << n - sub[x] - sub[y] << endl;
    }
  }
  return 0;
}
