#include <bits/stdc++.h>
using namespace std;
int n, m;
int final_ans;
int flagup[3];
int flagdown;
int tmpp[100005];
vector<int> p[100005];
int fat[100005][20], lev[100005], father[100005];
void dfs(int x, int fa) {
  father[x] = fa;
  fat[x][0] = fa;
  lev[x] = lev[fa] + 1;
  int e = p[x].size();
  for (int i = 0; i < e; i++) {
    int y = p[x][i];
    if (y == fa) continue;
    dfs(y, x);
  }
}
int lca(int x, int y) {
  if (lev[x] > lev[y]) swap(x, y);
  for (int i = 19; i >= 0; i--) {
    if (lev[fat[y][i]] >= lev[x]) {
      y = fat[y][i];
    }
  }
  for (int i = 19; i >= 0; i--) {
    if (fat[x][i] != fat[y][i]) {
      x = fat[x][i];
      y = fat[y][i];
    }
  }
  return (x == y) ? x : fat[x][0];
}
void intit() {
  int i, j;
  dfs(1, 0);
  for (i = 1; i <= 19; i++) {
    for (j = 0; j <= n; j++) {
      fat[j][i] = fat[fat[j][i - 1]][i - 1];
    }
  }
}
int find_dfs(int now, int fa) {
  int e = p[now].size();
  for (int i = 0; i < e; i++) {
    int y = p[now][i];
    if (y == fa) continue;
    tmpp[now] += find_dfs(y, now);
  }
  return tmpp[now];
}
int find_ans(int now, int kk) {
  int j = 0;
  while (kk) {
    if (kk % 2 == 1) {
      now = fat[now][j];
    }
    kk >>= 1;
    j++;
  }
  return now;
}
int main() {
  int u, v;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < 100005; i++) {
      p[i].clear();
    }
    for (int i = 0; i < n - 1; i++) {
      scanf("%d%d", &u, &v);
      p[u].push_back(v);
      p[v].push_back(u);
    }
    intit();
    scanf("%d", &m);
    for (int i = 1; i <= n; i++) tmpp[i] = 1;
    find_dfs(1, 0);
    int now;
    for (int i = 1; i <= m; i++) {
      scanf("%d%d", &u, &v);
      int root = lca(u, v);
      int k = lev[u] - lev[root] + lev[v] - lev[root];
      if (lev[u] < lev[v]) swap(u, v);
      if (u == v) {
        printf("%d\n", n);
        continue;
      }
      if (k % 2) {
        printf("0\n");
        continue;
      }
      if (lev[u] != lev[v]) {
        now = find_ans(u, k / 2);
        k = find_ans(u, k / 2 - 1);
        printf("%d\n", tmpp[now] - tmpp[k]);
        continue;
      }
      if (lev[u] == lev[v]) {
        now = find_ans(u, k / 2);
        int son1 = find_ans(u, k / 2 - 1);
        int son2 = find_ans(v, k / 2 - 1);
        printf("%d\n",
               tmpp[1] - tmpp[now] + tmpp[now] - tmpp[son1] - tmpp[son2]);
      }
    }
  }
}
