#include <bits/stdc++.h>
using namespace std;
vector<int> a[120005];
int n, m, father[120005], l[120005], deep[120005], num[120005], q[120005][30],
    r, o, x, y, s1, s2, lca, ll, t, d, u[30];
int build(int k, int pre) {
  father[k] = pre;
  deep[k] = deep[pre] + 1;
  num[k] = 1;
  q[k][1] = father[k];
  r = 1;
  o = 1;
  while (r * 2 <= deep[k]) {
    q[k][o + 1] = q[q[k][o]][o];
    o++;
    r *= 2;
  }
  for (int i = 0; i < l[k]; i++)
    if (a[k][i] != pre) num[k] = num[k] + build(a[k][i], k);
  return num[k];
}
void find(int xx, int yy) {
  if (father[xx] == father[yy]) {
    s1 = xx;
    s2 = yy;
    return;
  }
  r = 1;
  d = deep[xx];
  while (u[r] < d && q[xx][r] != q[yy][r]) r++;
  find(q[xx][r - 1], q[yy][r - 1]);
  return;
}
int preeee(int xx, int k) {
  if (k == 1) return father[xx];
  r = 1;
  while (u[r + 1] < k) r = r + 1;
  return preeee(q[xx][r], k - u[r]);
}
int main() {
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    scanf("%d%d", &x, &y);
    l[x]++;
    l[y]++;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  build(1, 0);
  o = 1;
  u[o] = 1;
  while (u[o] <= n) o++, u[o] = u[o - 1] * 2;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    if ((deep[x] - deep[y]) % 2 != 0)
      printf("0\n");
    else if (x == y)
      printf("%d\n", n);
    else if (deep[x] == deep[y]) {
      find(x, y);
      printf("%d\n", n - num[s1] - num[s2]);
    } else {
      if (deep[x] < deep[y]) swap(x, y);
      t = preeee(x, deep[x] - deep[y]);
      if (t == y) {
        lca = y;
        ll = (deep[x] + deep[y]) / 2 - deep[lca];
        if (ll == 1)
          printf("%d\n", num[father[x]] - num[x]);
        else {
          o = preeee(x, ll - 1);
          printf("%d\n", num[father[o]] - num[o]);
        }
      } else {
        find(t, y);
        lca = father[s1];
        ll = (deep[x] + deep[y]) / 2 - deep[lca];
        o = preeee(x, ll - 1);
        printf("%d\n", num[father[o]] - num[o]);
      }
    }
  }
  return 0;
}
