#include <bits/stdc++.h>
using namespace std;
const int INF = 100000009;
const int MAXN = 100001;
int n, m, q, x, y, timer, ans;
int t_in[MAXN], t_low[MAXN], parent[MAXN];
bool ind;
vector<vector<int> > g(MAXN);
map<pair<int, int>, int> bridge;
map<int, bool> used;
void DFS(int, int);
void _Find(int, int);
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    g[x].push_back(y);
    g[y].push_back(x);
  }
  DFS(1, 0);
  scanf("%d", &q);
  while (q--) {
    scanf("%d%d", &x, &y);
    ans = 0;
    ind = false;
    used.clear();
    _Find(x, y);
    printf("%d\n", ans);
  }
}
void DFS(int v, int p) {
  parent[v] = p;
  used[v] = true;
  t_in[v] = t_low[v] = ++timer;
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (to == p) continue;
    if (used[to])
      t_low[v] = min(t_low[v], t_in[to]);
    else {
      DFS(to, v);
      t_low[v] = min(t_low[v], t_low[to]);
      if (t_low[to] > t_in[v]) bridge[{v, to}] = 1;
    }
  }
}
void _Find(int v, int p) {
  used[v] = true;
  if (v == p) {
    ind = true;
    return;
  }
  for (int i = 0; i < g[v].size(); i++) {
    int to = g[v][i];
    if (!used[to] && !ind) {
      _Find(to, p);
      if (ind) ans += bridge[{v, to}] + bridge[{to, v}];
    }
  }
}
