#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n;
int T;
int pa[N];
int tin[N];
int tout[N];
int kp[N][20];
int d[N];
int sz[N];
vector<int> g[N];
void dfs(int x) {
  tin[x] = T++;
  sz[x] = 1;
  for (int i = 0; i < g[x].size(); ++i) {
    int y = g[x][i];
    if (y != pa[x]) {
      d[y] = d[x] + 1;
      pa[y] = x;
      dfs(y);
      sz[x] += sz[y];
    }
  }
  tout[x] = T++;
}
bool anc(int x, int y) { return tin[x] <= tin[y] && tout[x] >= tout[y]; }
int lca(int x, int y) {
  if (anc(x, y)) {
    return x;
  }
  for (int i = 19; i >= 0; --i) {
    if (!anc(kp[x][i], y)) {
      x = kp[x][i];
    }
  }
  return pa[x];
}
int get_kth(int x, int k) {
  for (int i = 19; i >= 0; --i) {
    if (k >= (1 << i)) {
      k -= (1 << i);
      x = kp[x][i];
    }
  }
  return x;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    g[i].clear();
  }
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x;
    --y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  T = 0;
  d[0] = 0;
  pa[0] = 0;
  dfs(0);
  for (int i = 0; i < n; ++i) {
    kp[i][0] = pa[i];
  }
  for (int j = 1; j < 20; ++j) {
    for (int i = 0; i < n; ++i) {
      kp[i][j] = kp[kp[i][j - 1]][j - 1];
    }
  }
  int qq;
  scanf("%d", &qq);
  while (qq--) {
    int x, y;
    scanf("%d %d", &x, &y);
    --x;
    --y;
    if (x == y) {
      printf("%d\n", n);
    } else {
      int z = lca(x, y);
      int dist = d[x] + d[y] - 2 * d[z];
      int ans = 0;
      if (dist % 2 == 0) {
        int middle = dist / 2;
        if (d[x] > d[y]) {
          ans += sz[get_kth(x, middle)];
          ans -= sz[get_kth(x, middle - 1)];
        } else if (d[y] > d[x]) {
          ans += sz[get_kth(y, middle)];
          ans -= sz[get_kth(y, middle - 1)];
        } else {
          ans += n;
          ans -= sz[get_kth(x, middle - 1)];
          ans -= sz[get_kth(y, middle - 1)];
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}
