#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
const int INF = 1e9 + 7;
int us[N], pr[N][30], h[N], sz[N];
int tin[N], tout[N], t = 1;
int n, m;
int x, y;
vector<int> g[N];
int dfs(int v, int p = 0) {
  tin[v] = t++;
  us[v] = 1;
  sz[v] = 1;
  pr[v][0] = p;
  h[v] = h[p] + 1;
  for (int i = 1; i < 20; i++) {
    pr[v][i] = pr[pr[v][i - 1]][i - 1];
  }
  for (int to : g[v])
    if (!us[to]) sz[v] += dfs(to, v);
  tout[v] = t++;
  return sz[v];
}
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
int path(int a, int b) {
  for (int i = 20; i >= 0; i--)
    if (!upper(pr[a][i], b) && pr[a][i] != 0) a = pr[a][i];
  return a;
}
pair<int, int> findp(int a, int b) {
  if (upper(a, b)) return make_pair(a, 0);
  if (upper(b, a)) return make_pair(b, -1);
  a = path(x, y);
  b = path(y, x);
  if (h[x] < h[y])
    return make_pair(pr[a][0], 0);
  else if (h[x] > h[y])
    return make_pair(pr[b][0], -1);
  else
    return make_pair(a, b);
}
int path2(int v, int l) {
  for (int i = 20; i >= 0; i--)
    if (h[y] - l < h[pr[v][i]] && h[pr[v][i]] > 0) v = pr[v][i];
  return v;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  dfs(1);
  scanf("%d", &m);
  while (m--) {
    scanf("%d%d", &x, &y);
    if (x == y) {
      printf("%d\n", n);
      continue;
    }
    pair<int, int> ch = findp(x, y);
    if (ch.second <= 0) {
      if (ch.second == -1) swap(x, y);
      int r = (h[x] + h[y]) - (2 * h[ch.first]);
      if (r % 2 == 1)
        puts("0");
      else {
        r /= 2;
        int v = path2(y, r);
        printf("%d\n", sz[pr[v][0]] - sz[v]);
      }
    } else {
      printf("%d\n", n - sz[ch.first] - sz[ch.second]);
    }
  }
}
