#include <bits/stdc++.h>
using namespace std;
int n, m, s, fir[1000010 * 2], sum, dep[1000010], f[1000010][19];
int poi[1000010], pan3;
struct zhs {
  int next;
  int to;
  int num_poi;
  void add(int x, int y) {
    next = fir[x];
    to = y;
    fir[x] = sum;
  }
} e[1000010 * 2];
void dfs(int x, int fa, int deep) {
  dep[x] = deep;
  for (int i = fir[x]; i; i = e[i].next) {
    if (e[i].to == fa) continue;
    f[e[i].to][0] = x;
    dfs(e[i].to, x, deep + 1);
    poi[x] += poi[e[i].to];
  }
  poi[x]++;
}
void dp() {
  for (int j = 1; j <= 18; j++)
    for (int i = 1; i <= n; i++) f[i][j] = f[f[i][j - 1]][j - 1];
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 18; i >= 0; i--) {
    if (dep[f[x][i]] >= dep[y]) x = f[x][i];
  }
  if (x == y) {
    pan3 = 1;
    return x;
  }
  for (int i = 18; i >= 0; i--) {
    if (f[x][i] == f[y][i] || !f[x][i] || !f[y][i]) continue;
    x = f[x][i];
    y = f[y][i];
  }
  return f[x][0];
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    e[++sum].add(a, b);
    e[++sum].add(b, a);
  }
  dfs(1, 0, 1);
  dp();
  cin >> m;
  for (int i = 1; i <= m; i++) {
    pan3 = 0;
    int a, b;
    scanf("%d%d", &a, &b);
    if (a == b) {
      cout << n << endl;
      continue;
    }
    if (abs(dep[a] - dep[b]) % 2 != 0) {
      cout << 0 << endl;
      continue;
    }
    int ace = lca(a, b);
    pan3 = 0;
    if (pan3 == 0) {
      int det1 = dep[a] - dep[ace], det2 = dep[b] - dep[ace];
      if (det1 == det2) {
        int mid = dep[ace] + 1;
        for (int i = 18; i >= 0; i--) {
          if (dep[f[a][i]] >= mid) a = f[a][i];
        }
        for (int i = 18; i >= 0; i--) {
          if (dep[f[b][i]] >= mid) b = f[b][i];
        }
        cout << poi[ace] - poi[a] - poi[b] + n - poi[ace] << endl;
        continue;
      }
      if (det1 < det2) {
        swap(a, b);
        swap(det1, det2);
      }
      int mid = dep[a] - ((det1 + det2) / 2);
      int b = a;
      for (int i = 18; i >= 0; i--) {
        if (dep[f[a][i]] >= mid) a = f[a][i];
      }
      for (int i = 18; i >= 0; i--) {
        if (dep[f[b][i]] >= mid + 1) b = f[b][i];
      }
      cout << poi[a] - poi[b] << endl;
    }
  }
  return 0;
}
