#include <bits/stdc++.h>
using namespace std;
inline char skipwhitespace() {
  char ch = getchar();
  while (ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t') ch = getchar();
  return ch;
}
void gi(int &x) {
  register int c = getchar();
  x = 0;
  int sn = 1;
  for (; (c < 48 || c > 57); c = getchar())
    if (c == '-') sn = -1;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  x *= sn;
}
void gii(long long int &x) {
  register long long int c = getchar();
  x = 0;
  long long int sn = 1;
  for (; (c < 48 || c > 57); c = getchar())
    if (c == '-') sn = -1;
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  x *= sn;
}
void wi(int n) {
  int sign = n >= 0 ? 1 : -1;
  n = n > 0 ? n : -n;
  char buf[10];
  int i = 9;
  if (!n) buf[i--] = 48;
  while (n) {
    buf[i--] = n % 10 + 48;
    n /= 10;
  }
  if (sign < 0) printf("%c", '-');
  while (++i < 10) printf("%c", buf[i]);
}
void wii(long long int n) {
  long long int sign = n >= 0 ? 1 : -1;
  n = n > 0 ? n : -n;
  char buf[25];
  long long int i = 24;
  if (!n) buf[i--] = 48;
  while (n) {
    buf[i--] = n % 10 + 48;
    n /= 10;
  }
  if (sign < 0) printf("%c", '-');
  while (++i < 25) printf("%c", buf[i]);
}
int gs(char *s) {
  char ch = skipwhitespace();
  int n = 0;
  while ((ch != '\n' && ch != ' ' && ch != '\t')) {
    s[n++] = ch;
    ch = getchar();
  }
  s[n] = 0;
  return n;
}
void ws(char *s) {
  char *p = s;
  while (*p) {
    printf("%c", *p);
    p++;
  }
}
int n, T[100005], p[100005][18], tsize[100005];
vector<int> adj[100005];
void dfs(int ver, int pre, int dep) {
  T[ver] = dep;
  p[ver][0] = pre;
  tsize[ver] = 1;
  for (__typeof((adj[ver]).end()) i = (adj[ver]).begin(); i != (adj[ver]).end();
       ++i)
    if (*i != pre) dfs(*i, ver, dep + 1), tsize[ver] += tsize[*i];
}
int lca(int x, int y) {
  if (x == y) return x;
  if (T[x] < T[y]) swap(x, y);
  int lg = 1;
  for (; (1 << lg) <= T[x]; lg++)
    ;
  lg--;
  for (int i = lg; i >= 0; i--)
    if (T[x] - (1 << i) >= T[y]) x = p[x][i];
  if (x == y) return x;
  for (int i = lg; i >= 0; i--)
    if (p[x][i] != -1 && p[x][i] != p[y][i]) x = p[x][i], y = p[y][i];
  return p[x][0];
}
void pre() {
  for (int i = 0; i < n + 1; i++)
    for (int j = 0; j < 18; j++) p[i][j] = -1;
  dfs(1, -1, 0);
  for (int j = 1; j <= 18 - 1; j++)
    for (int i = 1; i <= n; i++)
      if (p[i][j - 1] != -1) p[i][j] = p[p[i][j - 1]][j - 1];
}
int main() {
  gi(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    gi(x);
    gi(y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  pre();
  int q;
  gi(q);
  while (q--) {
    int x, y, LCA;
    gi(x);
    gi(y);
    if (x == y) {
      cout << n << endl;
      continue;
    }
    LCA = lca(x, y);
    if (T[x] == T[y]) {
      int lg, diff = T[x] - T[LCA] - 1;
      lg = 1;
      for (; (1 << lg) <= diff; lg++)
        ;
      lg--;
      for (int i = lg; i >= 0; i--)
        if (T[x] - (1 << i) >= T[LCA] + 1) x = p[x][i];
      for (int i = lg; i >= 0; i--)
        if (T[y] - (1 << i) >= T[LCA] + 1) y = p[y][i];
      cout << n - tsize[x] - tsize[y] << endl;
    } else {
      int lg, dist = T[x] + T[y] - 2 * T[LCA], aa, bb, temp;
      if (dist & 1)
        cout << "0" << endl;
      else {
        if (T[x] < T[y]) swap(x, y);
        lg = 1;
        for (; (1 << lg) <= (dist / 2); lg++)
          ;
        lg--;
        dist = (dist / 2);
        bb = x;
        temp = dist;
        for (int i = lg; i >= 0; i--)
          if (dist - (1 << i) >= 0) x = p[x][i], dist -= (1 << i);
        aa = x;
        x = bb;
        dist = temp - 1;
        for (int i = lg; i >= 0; i--)
          if (dist - (1 << i) >= 0) x = p[x][i], dist -= (1 << i);
        bb = x;
        cout << tsize[aa] - tsize[bb] << endl;
      }
    }
  }
  return 0;
}
