#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18 + 7;
const int maxN = 1 << 20;
int n, a, b, q, cnt;
int post[maxN], pre[maxN], dist[maxN], sz[maxN];
bool used[maxN];
int parent[maxN][21];
vector<int> graph[maxN];
void DFS(int start) {
  used[start] = true;
  pre[start] = cnt++;
  sz[start] = 1;
  for (auto x : graph[start]) {
    if (!used[x]) {
      parent[x][0] = start;
      dist[x] = dist[start] + 1;
      DFS(x);
      sz[start] += sz[x];
    }
  }
  post[start] = cnt;
}
bool children(int u, int v) { return pre[v] >= pre[u] && post[v] <= post[u]; }
void setParents() {
  for (int i = (1); i <= ((19)); ++i) {
    for (int j = (1); j <= ((n)); ++j) {
      parent[j][i] = parent[parent[j][i - 1]][i - 1];
    }
  }
}
int LCA(int a, int b) {
  if (children(a, b)) return a;
  if (children(b, a)) return b;
  int i = a, j = 19;
  while (j >= 0) {
    if (children(parent[i][j], b)) {
      j--;
    } else {
      i = parent[i][j];
    }
  }
  return parent[i][0];
}
int distance(int a, int b) { return dist[a] + dist[b] - 2 * dist[LCA(a, b)]; }
int findFrom(int a, int len) {
  std::bitset<19> b(len);
  for (int i = (18); i >= (0); --i) {
    if (b[i]) a = parent[a][i];
  }
  return a;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = (0); i <= ((n - 1) - 1); ++i) {
    cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  parent[1][0] = 1;
  DFS(1);
  setParents();
  cin >> q;
  for (int _ = (0); _ <= ((q)-1); ++_) {
    cin >> a >> b;
    if (a == b) {
      cout << n << endl;
      continue;
    }
    int d = distance(a, b);
    if (d % 2 == 1)
      cout << 0 << endl;
    else {
      int x = findFrom(a, d / 2);
      if (distance(a, x) != distance(b, x)) x = findFrom(b, d / 2);
      if (children(x, a)) {
        if (children(x, b)) {
          int v1 = findFrom(a, d / 2 - 1);
          int v2 = findFrom(b, d / 2 - 1);
          cout << n - sz[v2] - sz[v1] << endl;
        } else {
          int v = findFrom(a, d / 2 - 1);
          cout << sz[x] - sz[v] << endl;
        }
      } else {
        int v = findFrom(b, d / 2 - 1);
        cout << sz[x] - sz[v] << endl;
      }
    }
  }
  return 0;
}
