#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adj;
int H[100050], parent[100050], sz[100050], L[100050 << 1], E[100050 << 1],
    M[100050][20], SEG[(100050 << 3) + 15];
int n, timer;
int dfs(int node, int depth, int perr) {
  sz[node] = 1;
  H[node] = timer;
  E[timer] = node;
  L[timer++] = depth;
  parent[node] = perr;
  for (int i = 0; i < adj[node].size(); ++i) {
    if (adj[node][i] != perr) {
      sz[node] += dfs(adj[node][i], depth + 1, node);
      E[timer] = node;
      L[timer++] = depth;
    }
  }
  return sz[node];
}
void buildKthParent() {
  memset(M, -1, sizeof(M));
  for (int i = 0; i < n; ++i) M[i][0] = parent[i];
  for (int j = 1; (1 << j) < n; ++j)
    for (int i = 1; i < n; ++i)
      if (M[i][j - 1] != -1) M[i][j] = M[M[i][j - 1]][j - 1];
  return;
}
void construct(int index, int st, int en) {
  if (st == en) {
    SEG[index] = st;
    return;
  }
  if ((index << 1) + 2 < (100050 << 3)) {
    int mid = st + ((en - st) >> 1);
    construct((index << 1) + 1, st, mid);
    construct((index << 1) + 2, mid + 1, en);
    if (L[SEG[(index << 1) + 1]] < L[SEG[(index << 1) + 2]])
      SEG[index] = SEG[(index << 1) + 1];
    else
      SEG[index] = SEG[(index << 1) + 2];
  }
  return;
}
int Query(int index, int Rs, int Re, int first, int last) {
  if (Rs >= first and Re <= last) return SEG[index];
  if (Re < first || Rs > last) return timer;
  if ((index << 1) + 2 < (100050 << 3)) {
    int mid = Rs + ((Re - Rs) >> 1);
    int x = Query((index << 1) + 1, Rs, mid, first, last);
    int y = Query((index << 1) + 2, mid + 1, Re, first, last);
    if (L[x] < L[y]) return x;
    return y;
  }
  return timer;
}
int LCA(int u, int v) {
  int idx = Query(0, 0, timer - 1, H[u], H[v]);
  return E[idx];
}
int getKthParent(int node, int kth) {
  int lg = log2(L[H[node]]);
  for (int i = lg; i > -1; --i)
    while (L[H[node]] - (1 << i) >= kth) node = M[node][i];
  return node;
}
int main() {
  scanf("%d", &n);
  adj.resize(n + 5);
  for (int i = 1; i < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a - 1].push_back(b - 1);
    adj[b - 1].push_back(a - 1);
  }
  dfs(0, 0, -1);
  L[timer] = (1 << 30);
  buildKthParent();
  construct(0, 0, timer - 1);
  int m;
  scanf("%d", &m);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    if (H[a] > H[b]) swap(a, b);
    if (a == b) {
      printf("%d\n", n);
      continue;
    }
    int node = LCA(a, b);
    int len = L[H[a]] + L[H[b]] - (L[H[node]] << 1);
    if (len & 1)
      printf("0\n");
    else {
      int ans;
      if (L[H[a]] < L[H[b]]) swap(a, b);
      if (L[H[node]] < L[H[a]] and L[H[node]] < L[H[b]]) {
        len >>= 1;
        --len;
        int node1 = getKthParent(a, L[H[a]] - len);
        int node2 = parent[node1];
        if (node2 == node) {
          int node3 = getKthParent(b, L[H[b]] - len);
          ans = n - sz[node3] - sz[node1];
        } else
          ans = sz[node2] - sz[node1];
      } else {
        len >>= 1;
        --len;
        int node1 = getKthParent(a, L[H[a]] - len);
        int node2 = parent[node1];
        ans = sz[node2] - sz[node1];
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
