#include <bits/stdc++.h>
using namespace std;
vector<bool> used, used2;
vector<int> pay, s, l;
int g_v, g_to, k;
void dfs(vector<vector<int> > &g, int v) {
  used2[v] = true;
  for (vector<int>::iterator i = g[v].begin(); i != g[v].end(); ++i)
    if (!used2[*i] && *i != g_to) dfs(g, *i);
}
void dfs(vector<vector<int> > &g, vector<int> &tin, vector<int> &fup,
         int &timer, int v, int p = -1) {
  used[v] = true;
  tin[v] = fup[v] = timer++;
  for (size_t i = 0; i < g[v].size(); ++i) {
    int to = g[v][i];
    if (to == p) continue;
    if (used[to])
      fup[v] = min(fup[v], tin[to]);
    else {
      dfs(g, tin, fup, timer, to, v);
      fup[v] = min(fup[v], fup[to]);
      if (fup[to] > tin[v]) {
        g_to = to;
        used2.assign(g.size(), false);
        dfs(g, v);
        for (int j = 0; j < k; ++j) {
          if (used2[s[j]] != used2[l[j]]) {
            pay[j] += 1;
          }
        }
      }
    }
  }
}
void find_bridges(vector<vector<int> > &g) {
  int n = g.size();
  used.assign(n, false);
  used2.assign(n, false);
  int timer;
  vector<int> tin(n), fup(n);
  timer = 0;
  for (int i = 0; i < n; ++i)
    if (!used[i]) dfs(g, tin, fup, timer, i);
}
int main() {
  int n, m;
  vector<vector<int> > g;
  scanf("%d%d", &n, &m);
  g.resize(n);
  int a, b;
  for (int i = 0; i < m; ++i) {
    scanf("%d%d", &a, &b);
    g[a - 1].push_back(b - 1);
    g[b - 1].push_back(a - 1);
  }
  scanf("%d", &k);
  s.resize(k);
  l.resize(k);
  pay.resize(k);
  for (int i = 0; i < k; ++i) {
    scanf("%d%d", &s[i], &l[i]);
    --s[i];
    --l[i];
  }
  find_bridges(g);
  for (int i = 0; i < k; ++i) {
    printf("%i\n", pay[i]);
  }
}
