#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int maxl = 20;
int n, m;
vector<int> g[maxn];
bool marked[maxn];
int par[maxn][maxl];
int impNum[maxn][maxl];
int h[maxn];
int uh[maxn];
void dfs1(int v) {
  marked[v] = true;
  for (int i = 1; i < maxl; i++) {
    if (par[v][i - 1] != -1)
      par[v][i] = par[par[v][i - 1]][i - 1];
    else
      par[v][i] = -1;
  }
  uh[v] = 1e9;
  for (int u : g[v]) {
    if (!marked[u]) {
      h[u] = h[v] + 1;
      par[u][0] = v;
      dfs1(u);
      uh[v] = min(uh[v], uh[u]);
    } else if (u != par[v][0]) {
      uh[v] = min(uh[v], h[u]);
    }
  }
}
void dfs2(int v) {
  marked[v] = true;
  impNum[v][0] = 0;
  if (v != 0 && uh[v] >= h[v]) impNum[v][0] = 1;
  for (int i = 1; i < maxl; i++) {
    impNum[v][i] = impNum[v][i - 1] + impNum[par[v][i - 1]][i - 1];
  }
  for (int u : g[v]) {
    if (!marked[u]) dfs2(u);
  }
}
int findPar(int v, int p) {
  int hp = h[v] - p;
  for (int i = maxl - 1; i >= 0; i--) {
    if (par[v][i] != -1 && h[par[v][i]] >= hp) v = par[v][i];
  }
  return v;
}
int lca(int a, int b) {
  if (h[a] < h[b]) swap(a, b);
  a = findPar(a, h[a] - h[b]);
  if (a == b) return a;
  for (int i = maxl - 1; i >= 0; i--) {
    if (par[a][i] != par[b][i]) {
      a = par[a][i];
      b = par[b][i];
    }
  }
  return par[a][0];
}
int getTax(int v, int p) {
  int ans = 0;
  for (int i = maxl - 1; i >= 0; i--) {
    if (par[v][i] != -1 && h[par[v][i]] >= h[p]) {
      ans += impNum[v][i];
      v = par[v][i];
    }
  }
  return ans;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int v, u;
    cin >> v >> u;
    v--;
    u--;
    g[v].push_back(u);
    g[u].push_back(v);
  }
  par[0][0] = -1;
  h[0] = 0;
  dfs1(0);
  memset(marked, false, sizeof marked);
  dfs2(0);
  int k;
  cin >> k;
  while (k--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int parent = lca(a, b);
    cout << getTax(a, parent) + getTax(b, parent) << endl;
  }
  return 0;
}
