#include <bits/stdc++.h>
using namespace std;
bool isVowel(char ch) {
  ch = tolower(ch);
  return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}
const int N = 1e5 + 7;
vector<vector<int> > graph, grbr, up;
map<pair<int, int>, int> bridge;
int used[N], tin[N], fup[N], tinC[N], toutC[N], comp[N], timer, comN, l, dep[N];
void dfs2(int v, int p = 1, int d = 0) {
  tinC[v] = ++timer;
  dep[v] = d;
  int i, to;
  up[v][0] = p;
  for (i = 1; i <= l; i++) {
    up[v][i] = up[up[v][i - 1]][i - 1];
  }
  for (i = 0; i < grbr[v].size(); i++) {
    to = grbr[v][i];
    if (to != p) {
      dfs2(to, v, d + 1);
    }
  }
  toutC[v] = ++timer;
}
bool upper(int a, int b) { return tinC[a] <= tinC[b] && toutC[a] >= toutC[b]; }
int lca(int a, int b) {
  if (upper(a, b)) {
    return a;
  }
  if (upper(b, a)) {
    return b;
  }
  for (int i = l; i >= 0; i--) {
    if (!upper(up[a][i], b)) {
      a = up[a][i];
    }
  }
  return up[a][0];
}
void dfs1(int v, int p = 0) {
  if (bridge[make_pair(min(v, p), max(v, p))]) {
    comp[v] = ++comN;
    grbr[comp[p]].push_back(comp[v]);
    grbr[comp[v]].push_back(comp[p]);
  } else {
    comp[v] = comp[p];
  }
  used[v] = 1;
  int i, to;
  for (i = 0; i < graph[v].size(); i++) {
    to = graph[v][i];
    if (!used[to]) {
      dfs1(to, v);
    }
  }
}
void dfs(int v, int p = -1) {
  tin[v] = fup[v] = ++timer;
  used[v] = 1;
  int i, to;
  for (i = 0; i < graph[v].size(); i++) {
    to = graph[v][i];
    if (to == p) {
      continue;
    }
    if (used[to]) {
      fup[v] = min(fup[v], tin[to]);
    } else {
      dfs(to, v);
      fup[v] = min(fup[v], fup[to]);
      if (fup[to] > tin[v]) {
        bridge[make_pair(min(v, to), max(v, to))] = 1;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m, x, i, y;
  cin >> n >> m;
  graph.resize(n + 1);
  grbr.resize(n + 1);
  bridge[make_pair(0, 1)] = 1;
  for (i = 0; i < m; i++) {
    cin >> x >> y;
    graph[x].push_back(y);
    graph[y].push_back(x);
  }
  dfs(1);
  for (i = 1; i <= n; i++) {
    used[i] = 0;
  }
  dfs1(1);
  grbr[1].erase(grbr[1].begin());
  timer = 0;
  up.resize(comN + 1);
  while ((1 << l) <= comN) l++;
  for (i = 0; i <= comN; i++) {
    up[i].resize(l + 1);
  }
  dfs2(1);
  int k;
  cin >> k;
  while (k--) {
    int x, y;
    cin >> x >> y;
    int lac = lca(comp[x], comp[y]);
    cout << abs(dep[lac] - dep[comp[x]]) + abs(dep[lac] - dep[comp[y]]) << endl;
  }
  return 0;
}
