#include <bits/stdc++.h>
using namespace std;
namespace program {
int tot = 0, Next[200010 << 1], to[200010 << 1], head[200010 << 1];
int n, m, size[200010], fa[200010][30], bin[30], deep[200010];
inline void add(int x, int y) {
  tot += 1;
  Next[tot] = head[x];
  to[tot] = y;
  head[x] = tot;
}
inline void dfs(int x, int ffa) {
  size[x] = 1;
  deep[x] = deep[ffa] + 1;
  for (int i = 1; i <= 20; i++) {
    if (deep[x] - bin[i] < 0) break;
    fa[x][i] = fa[fa[x][i - 1]][i - 1];
  }
  for (int i = head[x]; i; i = Next[i]) {
    if (to[i] != ffa) {
      fa[to[i]][0] = x;
      dfs(to[i], x);
      size[x] += size[to[i]];
    }
  }
}
inline int get_lca(int x, int y) {
  if (deep[x] < deep[y]) {
    swap(x, y);
  }
  int k = deep[x] - deep[y];
  for (int i = 0; i <= 20; i++) {
    if ((k >> i) & 1) {
      x = fa[x][i];
    }
  }
  if (x == y) return y;
  for (int i = 20; i >= 0; i--) {
    if (fa[x][i] != fa[y][i]) {
      x = fa[x][i];
      y = fa[y][i];
    }
  }
  return fa[x][0];
}
inline int step(int x, int k) {
  for (int i = 0; i <= 20; i++) {
    if ((k >> i) & 1) {
      x = fa[x][i];
    }
  }
  return x;
}
inline void work() {
  cin >> n;
  for (int i = 1, x, y; i < n; i++) {
    cin >> x >> y;
    add(x, y);
    add(y, x);
  }
  bin[0] = 1;
  for (int i = 1; i <= 20; i++) {
    bin[i] = bin[i - 1] * 2;
  }
  dfs(1, 0);
  cin >> m;
  for (int i = 1, x, y; i <= m; i++) {
    cin >> x >> y;
    if (x == y) {
      cout << n << endl;
      continue;
    }
    int oo = get_lca(x, y);
    int res;
    int dis1 = deep[x] - deep[oo];
    int dis2 = deep[y] - deep[oo];
    if (dis1 == dis2) {
      int now1 = step(x, dis1 - 1);
      int now2 = step(y, dis2 - 1);
      res = n - size[now1] - size[now2];
    } else if (dis1 != dis2) {
      if ((dis1 + dis2) % 2 == 0) {
        if (deep[x] < deep[y]) {
          swap(x, y);
        }
        int now1 = step(x, (dis1 + dis2) / 2 - 1);
        int now2 = step(x, (dis1 + dis2) / 2);
        res = size[now2] - size[now1];
      } else {
        res = 0;
      }
    }
    cout << res << '\n';
  }
}
}  // namespace program
int main() {
  program::work();
  return 0;
}
