#include <bits/stdc++.h>
using namespace std;
const int SZ = 1e5 + 5;
int n;
vector<int> adj[SZ];
int p[SZ], parent[SZ][20], lvl[SZ], LOG[SZ], s[SZ];
void dfs(int cur) {
  parent[cur][0] = p[cur];
  s[cur] = 1;
  int cnt = 0;
  for (int i = 0; i < (int)adj[cur].size(); i++) {
    if (p[cur] != adj[cur][i]) {
      p[adj[cur][i]] = cur;
      lvl[adj[cur][i]] = lvl[cur] + 1;
      dfs(adj[cur][i]);
      cnt += s[adj[cur][i]];
    }
  }
  s[cur] += cnt;
}
int ansLCA(int u, int v) {
  if (lvl[u] < lvl[v]) swap(u, v);
  int cur = LOG[u];
  for (int i = cur; i >= 0; i--)
    if (lvl[u] - (1 << i) >= lvl[v]) u = parent[u][i];
  if (u == v) return u;
  for (int i = cur; i >= 0; i--) {
    if (parent[u][i] != parent[v][i]) {
      u = parent[u][i];
      v = parent[v][i];
    }
  }
  return p[u];
}
int getKth(int u, int k) {
  int i = 0;
  while (k) {
    if (k & 1) u = parent[u][i];
    i++;
    k >>= 1;
  }
  return u;
}
int main() {
  int u, v, q;
  scanf("%d", &n);
  for (int i = 0; 1 + i < n; i++) {
    scanf("%d %d", &u, &v);
    adj[u - 1].push_back(v - 1);
    adj[v - 1].push_back(u - 1);
  }
  p[0] = -1;
  dfs(0);
  for (int j = 1; (1 << j) < n; j++)
    for (int i = 0; i < n; i++)
      if (parent[i][j] != -1) parent[i][j] = parent[parent[i][j - 1]][j - 1];
  for (int i = 2; i <= n; i++) LOG[i] = LOG[i >> 1] + 1;
  scanf("%d", &q);
  while (q--) {
    scanf("%d %d", &u, &v);
    --u, --v;
    int meet = ansLCA(u, v);
    int d = lvl[u] + lvl[v] - 2 * lvl[meet];
    if (d & 1)
      printf("0\n");
    else if (u == v)
      printf("%d\n", n);
    else {
      if (lvl[u] < lvl[v]) swap(u, v);
      if (lvl[u] == lvl[v])
        printf("%d\n", n - s[getKth(u, d / 2 - 1)] - s[getKth(v, d / 2 - 1)]);
      else
        printf("%d\n", s[getKth(u, d / 2)] - s[getKth(u, d / 2 - 1)]);
    }
  }
}
