#include <bits/stdc++.h>
using namespace std;
const int inf(1010101010);
int n, m;
vector<vector<int> > adj;
vector<bool> seen;
vector<int> hh, low;
int par[100005][22];
int som[100005][22];
int get_par(int x, int h) {
  for (int i(19); ~i; i--)
    if (h & (1 << (i))) x = par[x][i];
  return x;
}
int lca(int x, int y) {
  if (hh[x] > hh[y]) x = get_par(x, hh[x] - hh[y]);
  if (hh[x] < hh[y]) y = get_par(y, hh[y] - hh[x]);
  assert(hh[x] == hh[y]);
  if (x == y) return x;
  for (int i(19); ~i; i--)
    if ((1 << (i)) <= hh[x]) {
      int xr(par[x][i]), yr(par[y][i]);
      if (xr - yr) x = xr, y = yr;
    }
  return par[x][0];
}
int tel(int x, int h) {
  int re(0);
  for (int i(19); ~i; i--) {
    if (h & (1 << (i))) re += som[x][i], x = par[x][i];
  }
  return re;
}
void dfs(int x, int pare, int h) {
  seen[x] = true, hh[x] = low[x] = h, par[x][0] = pare;
  for (__typeof((adj[x]).end()) it((adj[x]).begin()); it != ((adj[x]).end());
       ++it) {
    int y(*it);
    if (y == pare) continue;
    if (seen[y])
      low[x] = min(low[x], hh[y]);
    else {
      dfs(y, x, h + 1);
      low[x] = min(low[x], low[y]);
      if (low[y] > h) som[y][0]++;
    }
  }
}
void solve() {
  if (!(cin >> n >> m)) exit(0);
  seen = vector<bool>(n), hh = vector<int>(n), low = vector<int>(n),
  adj = vector<vector<int> >(n);
  while (m--) {
    int x, y;
    cin >> x >> y, x--, y--;
    adj[x].push_back(y), adj[y].push_back(x);
  }
  memset(par, -1, sizeof par), memset(som, 0, sizeof som);
  dfs(0, -1, 0);
  for (int d(0); d < (20); d++) {
    for (int i(0); i < (n); i++)
      if (~par[i][d]) par[i][d + 1] = par[par[i][d]][d];
  }
  for (int d(0); d < (20); d++) {
    for (int i(0); i < (n); i++)
      if (~par[i][d]) som[i][d + 1] = som[i][d] + som[par[i][d]][d];
  }
  int k;
  cin >> k;
  while (k--) {
    int x, y;
    cin >> x >> y, x--, y--;
    int z(lca(x, y));
    cout << tel(x, hh[x] - hh[z]) + tel(y, hh[y] - hh[z]) << endl;
  }
}
int main() {
  while (1) solve();
}
