#include <bits/stdc++.h>
using namespace std;
const int MM = 100009;
int n, lvl[MM], sz[MM], dp[MM][20], vis[MM], tt;
vector<int> v[MM];
void dfs(int x, int par) {
  if (vis[x]) return;
  vis[x] = 1;
  if (par == 0) {
    lvl[x] = 0;
  } else {
    lvl[x] = lvl[par] + 1;
    dp[x][0] = par;
  }
  tt++;
  int h = tt;
  for (int i = 0; i < v[x].size(); i++) dfs(v[x][i], x);
  sz[x] = tt - h;
}
void sp() {
  for (int j = 1; j < 20; j++)
    for (int i = 1; i <= n; i++) dp[i][j] = dp[dp[i][j - 1]][j - 1];
}
int u, df;
int lca(int x, int y) {
  if (lvl[x] < lvl[y]) swap(x, y);
  int h = lvl[x] - lvl[y];
  int x1 = x, y1 = y;
  for (int i = 0; i < 20; i++) {
    if ((h >> i) & 1) x = dp[x][i];
  }
  if (x == y) {
    x = x1;
    if (h % 2 != 0) return 0;
    h /= 2;
    int g = h;
    h--;
    for (int i = 0; i < 20; i++) {
      if ((h >> i) & 1) x = dp[x][i];
    }
    int o = dp[x][0];
    return sz[o] - sz[x];
  }
  for (int i = 19; i >= 0; i--)
    if (dp[x][i] != dp[y][i]) {
      x = dp[x][i];
      y = dp[y][i];
    }
  if (lvl[x1] == lvl[y1]) return n - sz[x] - sz[y] - 2;
  int u = dp[x][0];
  int k = lvl[x1] + lvl[y1] - 2 * lvl[u];
  if (k % 2 != 0) {
    return 0;
  }
  k /= 2;
  int f = x;
  x = x1;
  for (int i = 0; i < 20; i++) {
    if ((k >> i) & 1) x = dp[x][i];
  }
  k--;
  f = x1;
  for (int i = 0; i < 20; i++) {
    if ((k >> i) & 1) f = dp[f][i];
  }
  return sz[x] - sz[f];
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 0);
  sp();
  int q;
  cin >> q;
  while (q--) {
    int x, y;
    cin >> x >> y;
    if (x != y)
      cout << lca(x, y) << endl;
    else
      cout << n << endl;
  }
  return 0;
}
