#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int maxlog = 24;
int par[maxn][maxlog], h[maxn];
int siz[maxn];
bool mark[maxn];
int n;
vector<int> adj[maxn];
void dfs(int x) {
  mark[x] = 1;
  for (int i = 0; i < adj[x].size(); i++) {
    int child = adj[x][i];
    if (!mark[child]) {
      par[child][0] = x;
      h[child] = h[x] + 1;
      dfs(child);
      siz[x] += siz[child] + 1;
    }
  }
}
int LCAH(int fi, int se) {
  for (int i = maxlog - 1; i >= 0; i--)
    if (par[fi][i] != par[se][i]) {
      fi = par[fi][i];
      se = par[se][i];
    }
  return n - siz[fi] - siz[se] - 2;
}
int LCA(int fi, int se) {
  for (int i = maxlog - 1; i >= 0; i--)
    if (h[par[fi][i]] >= h[se]) fi = par[fi][i];
  if (fi == se) return fi;
  for (int i = maxlog - 1; i >= 0; i--)
    if (par[fi][i] != par[se][i]) {
      fi = par[fi][i];
      se = par[se][i];
    }
  return par[fi][0];
}
int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int fi, se;
    cin >> fi >> se;
    adj[fi].push_back(se);
    adj[se].push_back(fi);
  }
  dfs(1);
  for (int j = 1; j < maxlog; j++)
    for (int i = 1; i <= n; i++) par[i][j] = par[par[i][j - 1]][j - 1];
  int q;
  cin >> q;
  while (q--) {
    int fi, se;
    cin >> fi >> se;
    if (h[fi] < h[se]) swap(fi, se);
    int dis = h[fi] + h[se] - 2 * h[LCA(fi, se)];
    if (fi == se)
      cout << n << endl;
    else if (dis % 2 == 1)
      cout << 0 << endl;
    else if (h[fi] == h[se]) {
      cout << LCAH(fi, se) << endl;
    } else {
      dis /= 2;
      se = fi;
      for (int i = maxlog - 1; i >= 0; i--) {
        if ((1 << i) & dis) {
          fi = par[fi][i];
        }
      }
      int k = dis - 1;
      for (int i = maxlog - 1; i >= 0; i--) {
        if ((1 << i) & k) {
          se = par[se][i];
        }
      }
      cout << siz[fi] - siz[se] << endl;
    }
  }
  return 0;
}
