#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);
int n, l;
vector<int> g[100100];
int tin[100100], tout[100100];
int timer = 0;
int up[100100][20];
int d[100100], lvl[100100];
void dfs1(int v, int p = -1, int deg = 0) {
  d[v] = 1;
  lvl[v] = deg;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (to != p) {
      dfs1(to, v, deg + 1);
      d[v] += d[to];
    }
  }
}
void dfs(int v, int p = 0) {
  tin[v] = ++timer;
  up[v][0] = p;
  for (int i = 1; i <= l; ++i) up[v][i] = up[up[v][i - 1]][i - 1];
  for (size_t i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (to != p) dfs(to, v);
  }
  tout[v] = ++timer;
}
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
int lca(int a, int b) {
  if (upper(a, b)) return a;
  if (upper(b, a)) return b;
  for (int i = l; i >= 0; --i)
    if (!upper(up[a][i], b)) a = up[a][i];
  return up[a][0];
}
int get(int a, int st) {
  int nd = lvl[a] - st;
  assert(nd >= 0);
  int na = a;
  for (int i = l; i >= 0; i--) {
    int p = (1 << i);
    if (lvl[na] - p >= nd) na = up[na][i];
  }
  return na;
}
int main() {
  scanf("%d", &n);
  for (int i = 0, x, y; i < n - 1; i++) {
    scanf("%d%d", &x, &y);
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  l = 1;
  while ((1 << l) <= n) ++l;
  dfs(0);
  dfs1(0);
  int m;
  scanf("%d", &m);
  for (int i = 0, x, y; i < m; i++) {
    scanf("%d%d", &x, &y);
    x--;
    y--;
    if (x == y) {
      printf("%d\n", n);
      continue;
    }
    if (lvl[x] > lvl[y]) swap(x, y);
    int z = lca(x, y);
    if (z == x) {
      int len = lvl[y] - lvl[x];
      if (len % 2)
        printf("0\n");
      else {
        int ny = get(y, len / 2);
        int yy = get(y, len / 2 - 1);
        int ans = d[ny] - d[yy];
        printf("%d\n", ans);
      }
    } else {
      int len = lvl[x] - lvl[z] + lvl[y] - lvl[z];
      if (len % 2)
        printf("0\n");
      else {
        int ny = get(y, len / 2);
        if (ny == z) {
          int xx = get(x, len / 2 - 1);
          int yy = get(y, len / 2 - 1);
          int ans = n - d[xx] - d[yy];
          printf("%d\n", ans);
        } else {
          int yy = get(y, len / 2 - 1);
          int ans = d[ny] - d[yy];
          printf("%d\n", ans);
        }
      }
    }
  }
  return 0;
}
