#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
const int DEG = 20;
struct Edge {
  int to, next;
} edge[MAXN * 2];
int head[MAXN], tot;
void addedge(int u, int v) {
  edge[tot].to = v;
  edge[tot].next = head[u];
  head[u] = tot++;
}
void init() {
  tot = 0;
  memset(head, -1, sizeof(head));
}
int fa[MAXN][DEG];
int deg[MAXN];
int child_sum[100010];
void dfs(int u, int f) {
  if (u == f) {
    fa[u][0] = u;
  }
  child_sum[u] = 1;
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int v = edge[i].to;
    if (v == f) continue;
    deg[v] = deg[u] + 1;
    fa[v][0] = u;
    for (int j = 1; j < DEG; j++) {
      fa[v][j] = fa[fa[v][j - 1]][j - 1];
    }
    dfs(v, u);
    child_sum[u] += child_sum[v];
  }
}
int LCA(int u, int v) {
  if (deg[u] > deg[v]) swap(u, v);
  int hu = deg[u], hv = deg[v];
  int tu = u, tv = v;
  for (int det = hv - hu, i = 0; det; det >>= 1, i++)
    if (det & 1) tv = fa[tv][i];
  if (tu == tv) return tu;
  for (int i = DEG - 1; i >= 0; i--) {
    if (fa[tu][i] == fa[tv][i]) continue;
    tu = fa[tu][i];
    tv = fa[tv][i];
  }
  return fa[tu][0];
}
int dis(int u, int t) {
  if (deg[u] > deg[t]) swap(u, t);
  return deg[t] - deg[u];
}
int find(int u, int t, int d) {
  if (deg[u] < deg[t]) swap(u, t);
  if (d == 0) return t;
  int dd = dis(u, t);
  if (dd == d) return u;
  int p = -1;
  for (int i = DEG - 1; i >= 0; --i) {
    {
      int f = fa[u][i];
      if (f == 0) continue;
      if (deg[f] < deg[t]) continue;
      int dd = dis(f, t);
      if (dd > d) {
        u = f;
      } else if (dd == d) {
        return f;
      }
    }
  }
  return -1;
}
int dfs2(int u, int t, int f) {
  if (u == t) return 1;
  for (int i = head[u]; i != -1; i = edge[i].next) {
    int v = edge[i].to;
    if (v != f) {
      int ret = dfs2(v, t, u);
      if (ret > 0) return ret + 1;
    }
  }
  return 0;
}
int main() {
  int T;
  int n;
  int u, v;
  {
    scanf("%d", &n);
    init();
    for (int i = 1; i < n; i++) {
      scanf("%d%d", &u, &v);
      addedge(u, v);
      addedge(v, u);
    }
    dfs(1, 1);
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
      scanf("%d%d", &u, &v);
      int t = LCA(u, v);
      int dis1 = deg[u] - deg[t];
      int dis2 = deg[v] - deg[t];
      int node = -1;
      int ok = 0;
      int ans = 0;
      if ((dis1 - dis2) % 2 == 0) {
        if (u == v) {
          node = t;
          ans = n;
        } else if (u != t && t != v) {
          if (dis1 == dis2) {
            node = t;
            ok = 1;
            int node1 = find(u, t, 1);
            ans = child_sum[node1];
            node1 = find(v, t, 1);
            ans += child_sum[node1];
            ans = n - ans;
          } else {
            if (dis1 > dis2) {
              node = find(u, t, dis1 - (dis1 + dis2) / 2);
              if (node != -1) {
                int node1 = find(u, node, 1);
                ans = child_sum[node] - child_sum[node1];
              }
            } else {
              node = find(v, t, dis2 - (dis1 + dis2) / 2);
              if (node != -1) {
                int node1 = find(v, node, 1);
                ans = child_sum[node] - child_sum[node1];
              }
            }
          }
        } else {
          int nima = dis2 > dis1 ? dis2 - dis1 : dis1 - dis2;
          if (u != t) {
            node = find(u == t ? v : u, t, nima >> 1);
            if (node != -1) {
              int node1 = find(u, node, 1);
              ans = child_sum[node] - child_sum[node1];
            }
          } else {
            node = find(u == t ? v : u, t, nima >> 1);
            if (node != -1) {
              int node1 = find(v, node, 1);
              ans = child_sum[node] - child_sum[node1];
            }
          }
        }
      }
      if (node == -1) {
        cout << 0 << endl;
      } else {
        cout << ans << endl;
      }
    }
  }
  return 0;
}
