#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
int aabs(int a) {
  if (a < 0) return -a;
  return a;
}
int gcd(int a, int b) {
  while (a > 0 && b > 0) {
    if (a > b) {
      a %= b;
    } else {
      b %= a;
    }
  }
  return a + b;
}
vector<int> g[100013];
bool used[100013];
int timer;
int fup[100013], tin[100013];
vector<pair<int, int> > briges;
set<pair<int, int> > setbriges;
set<int> newv;
map<int, int> oldvnewv;
int newn;
void dfs(int v, int p = -1) {
  used[v] = 1;
  tin[v] = timer;
  fup[v] = timer;
  timer++;
  for (int i = 0; i < g[v].size(); i++) {
    if (g[v][i] == p) continue;
    if (used[g[v][i]])
      fup[v] = min(fup[v], tin[g[v][i]]);
    else {
      dfs(g[v][i], v);
      fup[v] = min(fup[v], fup[g[v][i]]);
      if (fup[g[v][i]] > tin[v]) {
        briges.push_back(make_pair(v, g[v][i]));
        setbriges.insert(make_pair(v, g[v][i]));
      }
    }
  }
}
void dfsfupper(int v, int p = -1) {
  used[v] = 1;
  if (p >= 0) {
    fup[v] = fup[p];
  }
  for (int i = 0; i < g[v].size(); i++) {
    if (!used[g[v][i]]) {
      if (setbriges.find(make_pair(v, g[v][i])) != setbriges.end() ||
          setbriges.find(make_pair(g[v][i], v)) != setbriges.end()) {
        dfsfupper(g[v][i]);
      } else {
        dfsfupper(g[v][i], v);
      }
    }
  }
}
int l;
int tout[100013];
vector<int> up[100013];
void dfs2(int v, int p = 0) {
  timer++;
  tin[v] = timer;
  up[v][0] = p;
  for (int i = 1; i <= l; ++i) up[v][i] = up[up[v][i - 1]][i - 1];
  for (int i = 0; i < g[v].size(); i++) {
    if (g[v][i] != p) {
      dfs2(g[v][i], v);
    }
  }
  timer++;
  tout[v] = timer;
}
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[b] <= tout[a]; }
int calc(int a, int b) {
  if (a == b) {
    return 0;
  }
  if (upper(a, b)) {
    int res = 0;
    for (int i = l; i >= 0; --i) {
      if (!upper(up[b][i], a)) {
        b = up[b][i];
        res += 1 << i;
      }
    }
    return res + 1;
  }
  if (upper(b, a)) {
    int res = 0;
    for (int i = l; i >= 0; --i) {
      if (!upper(up[a][i], b)) {
        a = up[a][i];
        res += 1 << i;
      }
    }
    return res + 1;
  }
  int res = 0;
  for (int i = l; i >= 0; --i) {
    if (!upper(up[a][i], b)) {
      a = up[a][i];
      res += 1 << i;
    }
  }
  return res + 1 + calc(up[a][0], b);
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    t1--;
    t2--;
    g[t1].push_back(t2);
    g[t2].push_back(t1);
  }
  memset(used, 0, sizeof(used));
  timer = 0;
  dfs(0);
  memset(used, 0, sizeof(used));
  dfsfupper(0);
  for (int i = 0; i < n; i++) {
    newv.insert(fup[i]);
  }
  int newn = 0;
  for (set<int>::iterator it = newv.begin(); it != newv.end(); it++) {
    oldvnewv[(*it)] = newn;
    newn++;
  }
  for (int i = 0; i < n; i++) {
    g[i].clear();
  }
  for (int i = 0; i < briges.size(); i++) {
    g[oldvnewv[fup[briges[i].first]]].push_back(
        oldvnewv[fup[briges[i].second]]);
    g[oldvnewv[fup[briges[i].second]]].push_back(
        oldvnewv[fup[briges[i].first]]);
  }
  n = newn;
  int k;
  cin >> k;
  timer = 0;
  l = 1;
  while ((1 << l) <= n) ++l;
  for (int i = 0; i < n; i++) {
    up[i].resize(l + 1);
  }
  dfs2(0);
  for (int i = 0; i < k; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    t1--;
    t2--;
    cout << calc(oldvnewv[fup[t1]], oldvnewv[fup[t2]]) << '\n';
  }
  return 0;
}
