#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, t, L, l, aa, bb, rez, p1, p2, depth[100015], tin[100015],
    tout[100015], up[100015][20];
vector<int> a[100015];
void dfs(int v, int p, int d) {
  tin[v] = t++;
  depth[v] = d;
  up[v][0] = p;
  for (int i = 1; i <= L; ++i) {
    up[v][i] = up[up[v][i - 1]][i - 1];
  }
  for (int u : a[v]) {
    if (u != p) {
      dfs(u, v, d + 1);
    }
  }
  tout[v] = t++;
}
bool is_ancestor(int u, int v) {
  return tin[u] <= tin[v] && tout[u] >= tout[v];
}
int lca(int u, int v) {
  if (is_ancestor(u, v)) {
    return u;
  }
  if (is_ancestor(v, u)) {
    return v;
  }
  for (int i = L; i >= 0; --i) {
    if (!is_ancestor(up[u][i], v)) {
      u = up[u][i];
    }
  }
  return up[u][0];
}
int dist(int u, int v) {
  int z = lca(u, v);
  return depth[u] - depth[z] + depth[v] - depth[z];
}
int lca_betbikzemaak(int u, int v) {
  for (int i = L; i >= 0; --i) {
    if (!is_ancestor(up[u][i], v)) {
      u = up[u][i];
    }
  }
  return u;
}
int meow(int u, int j) {
  int k = 0;
  int p = u;
  for (int i = L; i >= 0; --i) {
    if (k + (1 << i) <= j) {
      p = up[p][i];
      k += (1 << i);
    }
  }
  return p;
}
int main() {
  int d;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  L = ceil(log2(n));
  dfs(1, 1, 0);
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> x >> y;
    if (x == y) {
      rez = n;
    } else {
      d = dist(x, y);
      l = lca(x, y);
      if (d % 2 == 1) {
        rez = 0;
      } else if (dist(x, l) == dist(y, l)) {
        aa = lca_betbikzemaak(x, y);
        bb = lca_betbikzemaak(y, x);
        rez =
            n - ((tout[aa] - tin[aa] + 1) / 2) - ((tout[bb] - tin[bb] + 1) / 2);
      } else {
        if (depth[x] < depth[y]) {
          swap(x, y);
        }
        p1 = meow(x, dist(x, y) / 2);
        p2 = meow(x, dist(x, y) / 2 - 1);
        rez = ((tout[p1] - tin[p1] + 1) / 2) - ((tout[p2] - tin[p2] + 1) / 2);
      }
    }
    cout << rez << "\n";
  }
  return 0;
}
