#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const long long int MAX = -1000000000000000000;
const long long int MIN = 1000000000000000000;
const long long int inf = 1000000000;
const long long int KOK = 100000;
const long long int LOG = 30;
const long long int li = 100005;
const long long int mod = 1000000007;
int n, m, b, a, k, flag, cev, x, y, fa[li], baba[li][LOG + 10], dep[li], debug;
string s;
vector<int> v[li];
void dfs(int node, int ata, int depth) {
  baba[node][0] = ata;
  dep[node] = depth;
  fa[node] = 1;
  for (int i = 0; i < (int)v[node].size(); i++) {
    int go = v[node][i];
    if (go == ata) continue;
    dfs(go, node, depth + 1);
    fa[node] += fa[go];
  }
}
void build_lca() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j < LOG; j++) {
      baba[i][j] = baba[baba[i][j - 1]][j - 1];
    }
  }
}
int ask_lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  int fark = dep[x] - dep[y];
  for (int i = LOG - 1; i >= 0; i--) {
    if (fark >= (1 << i)) {
      debug += (1 << i);
      fark -= (1 << i);
      x = baba[x][i];
    }
  }
  if (x == y) return x;
  for (int i = LOG - 1; i >= 0; i--) {
    if (baba[x][i] == baba[y][i]) continue;
    x = baba[x][i];
    debug += (1 << i);
    y = baba[y][i];
  }
  debug++;
  return baba[x][0];
}
int find_root(int x, int fark) {
  int fark1 = fark;
  for (int i = LOG - 1; i >= 0; i--) {
    if (fark1 >= (1 << i)) {
      fark1 -= (1 << i);
      x = baba[x][i];
    }
  }
  return x;
}
int main(void) {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d %d", &x, &y);
    v[x].push_back(y);
    v[y].push_back(x);
  }
  dfs(1, 0, 0);
  build_lca();
  int q = 0;
  scanf("%d", &q);
  while (q--) {
    debug = 0;
    scanf("%d %d", &a, &b);
    if (b == a) {
      printf("%d\n", n);
      continue;
    }
    int lca = ask_lca(a, b);
    if ((dep[a] + dep[b] - (dep[lca] * 2)) % 2 == 1) {
      printf("0\n");
      continue;
    }
    if ((dep[a] - (dep[lca])) == (dep[b] - (dep[lca]))) {
      printf("%d\n",
             fa[1] - fa[find_root(a, debug - 1)] - fa[find_root(b, debug - 1)]);
      continue;
    }
    int yes = 0, yes1 = 0;
    int at = (dep[a] + dep[b] - (dep[lca] * 2)) / 2;
    if ((dep[a] - (dep[lca])) > (dep[b] - (dep[lca]))) {
      yes = find_root(a, at);
      yes1 = find_root(a, at - 1);
    } else {
      yes = find_root(b, at);
      yes1 = find_root(b, at - 1);
    }
    printf("%d\n", fa[yes] - fa[yes1]);
  }
  return 0;
}
