#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
const int N = 1e5 + 5;
int tin[N], tout[N];
char used[N];
vector<int> g[N];
int lca[N][20];
int sz[N];
int d[N];
int timer = 0;
void dfs(int v, int p, int dist) {
  used[v] = true;
  tin[v] = ++timer;
  d[v] = dist;
  sz[v] = 1;
  lca[v][0] = p;
  for (int i = 1; i < 19; i++) {
    lca[v][i] = lca[lca[v][i - 1]][i - 1];
  }
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (used[to]) continue;
    dfs(to, v, dist + 1);
    sz[v] += sz[to];
  }
  tout[v] = ++timer;
}
bool anc(int a, int b) { return tin[a] <= tin[b] && tout[b] <= tout[a]; }
int getf(int a, int b) {
  for (int i = 18; i >= 0; i--) {
    if (!anc(lca[a][i], b)) a = lca[a][i];
  }
  return a;
}
int get_lca(int a, int b) {
  if (anc(a, b)) return a;
  if (anc(b, a)) return b;
  for (int i = 18; i >= 0; i--) {
    if (!anc(lca[a][i], b)) a = lca[a][i];
  }
  return lca[a][0];
}
void solve() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    g[a].push_back(b);
    g[b].push_back(a);
  }
  dfs(1, 1, 0);
  int m;
  scanf("%d", &m);
  while (m--) {
    int a, b;
    scanf("%d %d", &a, &b);
    if (a == b) {
      printf("%d\n", n);
      continue;
    }
    int p = get_lca(a, b);
    int dist = d[a] + d[b] - 2 * d[p];
    if (dist & 1) {
      printf("0\n");
      continue;
    }
    if (d[a] - d[p] == d[b] - d[p]) {
      a = getf(a, p);
      b = getf(b, p);
      printf("%d\n", n - sz[a] - sz[b]);
      continue;
    }
    if (d[a] > d[b]) swap(a, b);
    int md = d[b] + d[a] - 2 * d[p] >> 1;
    int md1 = md - 1;
    int crb = b;
    for (int i = 0; md; md >>= 1, i++) {
      if (md & 1) {
        crb = lca[crb][i];
      }
    }
    int crf = b;
    for (int i = 0; md1; md1 >>= 1, i++) {
      if (md1 & 1) {
        crf = lca[crf][i];
      }
    }
    printf("%d\n", sz[crb] - sz[crf]);
  }
}
