#include <bits/stdc++.h>
using namespace std;
std::vector<int> adjList[100010];
int anc[100010][32], size[100010], depth[100010];
int tin[100010], tout[100010], timer = 1;
int N, m, u, v;
bool ancestor(int a, int b) {
  if ((tin[a] <= tin[b]) && (tout[b] <= tout[a])) return true;
  return false;
}
void dfs(int curr_node, int parent, int d) {
  depth[curr_node] = d;
  size[curr_node] = 1;
  tin[curr_node] = timer++;
  anc[curr_node][0] = parent;
  for (int i = 1; i < 32; i++)
    anc[curr_node][i] = anc[anc[curr_node][i - 1]][i - 1];
  for (int i = 0; i < adjList[curr_node].size(); i++) {
    if (adjList[curr_node][i] != parent) {
      dfs(adjList[curr_node][i], curr_node, d + 1);
      size[curr_node] = size[curr_node] + size[adjList[curr_node][i]];
    }
  }
  tout[curr_node] = timer++;
}
int goup(int a, int b) {
  for (int i = 31; i >= 0; i--) {
    if (!ancestor(anc[a][i], b)) a = anc[a][i];
  }
  return a;
}
int lca(int a, int b) {
  if (ancestor(a, b)) return a;
  if (ancestor(b, a)) return b;
  for (int i = 31; i >= 0; i--) {
    if (!ancestor(anc[a][i], b)) a = anc[a][i];
  }
  return anc[a][0];
}
int query(int a, int b) {
  int l = lca(a, b);
  if (a == b) return N;
  if (depth[a] - depth[l] == depth[b] - depth[l]) {
    return N - size[goup(a, l)] - size[goup(b, l)];
  }
  if (depth[a] < depth[b]) swap(a, b);
  int dist = depth[a] + depth[b] - 2 * depth[l];
  if (dist % 2 == 1) return 0;
  dist /= 2;
  int to = a;
  for (int i = 31; i >= 0; i--) {
    if (depth[a] - depth[anc[to][i]] < dist) to = anc[to][i];
  }
  return size[anc[to][0]] - size[to];
}
int main() {
  scanf("%d", &N);
  timer = 1;
  memset(anc, 0, sizeof(anc));
  for (int i = 1; i <= N - 1; i++) {
    scanf("%d", &u);
    scanf("%d", &v);
    adjList[u].push_back(v);
    adjList[v].push_back(u);
  }
  dfs(1, 1, 0);
  int q;
  scanf("%d", &q);
  while (q--) {
    scanf("%d", &u);
    scanf("%d", &v);
    cout << query(u, v) << endl;
  }
  return 0;
}
