#include <bits/stdc++.h>
using namespace std;
int n;
int T[100010], P[100010][25], L[100010], sz[100010];
vector<int> adj[100010];
void dfs(int from, int u, int dep) {
  T[u] = from;
  L[u] = dep;
  sz[u] = 1;
  for (int i = 0; i < (int)adj[u].size(); i++) {
    int v = adj[u][i];
    if (v == from) continue;
    dfs(u, v, dep + 1);
    sz[u] += sz[v];
  }
}
void init() {
  int i, j;
  for (i = 1; i <= n; i++)
    for (j = 0; 1 << j < n; j++) P[i][j] = -1;
  for (i = 1; i <= n; i++) P[i][0] = T[i];
  for (j = 1; 1 << j < n; j++)
    for (i = 1; i <= n; i++)
      if (P[i][j - 1] != -1) P[i][j] = P[P[i][j - 1]][j - 1];
}
int lca(int p, int q) {
  int tmp, log, i;
  if (L[p] < L[q]) tmp = p, p = q, q = tmp;
  for (log = 1; 1 << log <= L[p]; log++)
    ;
  log--;
  for (i = log; i >= 0; i--)
    if (L[p] - (1 << i) >= L[q]) p = P[p][i];
  if (p == q) return p;
  for (i = log; i >= 0; i--)
    if (P[p][i] != -1 && P[p][i] != P[q][i]) p = P[p][i], q = P[q][i];
  return T[p];
}
int klevpar(int u, int k) {
  int log, i;
  for (log = 1; 1 << log <= L[u]; log++)
    ;
  log--;
  for (i = log; i >= 0; i--)
    if (L[u] - (1 << i) >= k) u = P[u][i];
  return u;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1, 1, 0);
  init();
  int m;
  scanf("%d", &m);
  while (m--) {
    int x, y;
    scanf("%d %d", &x, &y);
    if (x == y) {
      printf("%d\n", n);
      continue;
    }
    int l = lca(x, y);
    int ans = 0;
    if (l != x && l != y) {
      int dist = L[x] + L[y] - 2 * L[l];
      if (!(dist & 1)) {
        if (L[y] < L[x]) swap(x, y);
        int kp = klevpar(y, L[y] - (dist >> 1));
        if (kp == l) {
          ans = sz[1];
          int xp = klevpar(x, L[kp] + 1);
          int yp = klevpar(y, L[kp] + 1);
          ans -= sz[xp];
          if (xp != yp) ans -= sz[yp];
        } else {
          ans = sz[kp];
          int yp = klevpar(y, L[kp] + 1);
          ans -= sz[yp];
        }
      }
    } else {
      if (y == l) swap(x, y);
      if ((L[x] & 1) == (L[y] & 1)) {
        int ly = (L[x] + L[y]) >> 1;
        int kp = klevpar(y, ly);
        ans = sz[kp];
        int yp = klevpar(y, ly + 1);
        ans -= sz[yp];
      }
    }
    printf("%d\n", ans);
  }
}
