#include <bits/stdc++.h>
using namespace std;
int p[(1 << 17)][17], dep[100001], num[100001];
vector<int> E[100001];
void dfs(int u) {
  num[u] = 1;
  for (int i = 0; i < E[u].size(); i++) {
    int v = E[u][i];
    if (v != p[u][0]) {
      p[v][0] = u, dep[v] = dep[u] + 1;
      for (int i = 1; i < 17; i++) p[v][i] = p[p[v][i - 1]][i - 1];
      dfs(v);
      num[u] += num[v];
    }
  }
}
int get(int x, int d) {
  for (int i = 0; i < 17; i++)
    if (d & (1 << i)) x = p[x][i];
  return x;
}
int LCA(int x, int y) {
  x = get(x, dep[x] - dep[y]);
  if (x == y) return x;
  for (int i = 16; i >= 0; i--)
    if (p[x][i] != p[y][i]) x = p[x][i], y = p[y][i];
  return p[x][0];
}
int main() {
  int n, m, x, y;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i <= n; i++) E[i].clear();
    for (int i = 0; i < n - 1; i++) {
      scanf("%d%d", &x, &y);
      E[x].push_back(y);
      E[y].push_back(x);
    }
    scanf("%d", &m);
    for (int i = 1; i < 17; i++) p[1][i] = 1;
    dfs(1);
    while (m--) {
      scanf("%d%d", &x, &y);
      if (x == y)
        printf("%d\n", n);
      else {
        if (dep[x] < dep[y]) swap(x, y);
        int z = LCA(x, y);
        int d = dep[x] - dep[z] + dep[y] - dep[z];
        if (d % 2 == 1)
          puts("0");
        else {
          d /= 2;
          int u = get(x, d);
          if (u == z) {
            x = get(x, d - 1);
            y = get(y, d - 1);
            printf("%d\n", n - num[x] - num[y]);
          } else {
            x = get(x, d - 1);
            printf("%d\n", num[u] - num[x]);
          }
        }
      }
    }
  }
}
