#include <bits/stdc++.h>
using namespace std;
const int MAX = 100000 + 5;
const int MAXM = 2 * MAX;
int head[MAX], nxt[MAXM], to[MAXM], lst;
int dfstime[MAX], low[MAX], Time;
int isbridge[MAX];
int numbridges[MAX];
int vis[MAX], visID;
int par[MAX][17];
int depth[MAX];
int n, m;
inline void addEdge(int f, int t) {
  nxt[lst] = head[f];
  head[f] = lst;
  to[lst++] = t;
}
inline void addBiEdge(int a, int b) {
  addEdge(a, b);
  addEdge(b, a);
}
void makebridges(int src, int from) {
  assert(vis[src] != visID);
  vis[src] = visID;
  dfstime[src] = low[src] = ++Time;
  for (int i = head[src]; ~i; i = nxt[i]) {
    int t = to[i];
    if (t == from) continue;
    if (vis[t] == visID)
      low[src] = min(low[src], dfstime[t]);
    else {
      makebridges(t, src);
      low[src] = min(low[src], low[t]);
      if (low[t] > dfstime[src]) isbridge[i] = isbridge[i ^ 1] = 1;
    }
  }
}
void makeTree(int src, int numb, int p, int d) {
  assert(vis[src] != visID);
  vis[src] = visID;
  numbridges[src] = numb;
  par[src][0] = p;
  depth[src] = d;
  for (int i = head[src]; ~i; i = nxt[i]) {
    int t = to[i];
    if (vis[t] == visID) continue;
    makeTree(t, numb + isbridge[i], src, d + 1);
  }
}
int lca(int a, int b) {
  if (depth[a] < depth[b]) swap(a, b);
  int d = depth[a] - depth[b];
  for (int i = 16; i >= 0; i--)
    if ((d >> i) & 1) a = par[a][i];
  if (a == b) return a;
  for (int i = 16; i >= 0; i--)
    if (par[a][i] != par[b][i]) a = par[a][i], b = par[b][i];
  return par[a][0];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  memset(head, -1, sizeof head);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    addBiEdge(a, b);
  }
  visID++;
  makebridges(1, -1);
  visID++;
  makeTree(1, 0, 0, 0);
  for (int j = 1; j <= 16; j++)
    for (int i = 1; i <= n; i++) par[i][j] = par[par[i][j - 1]][j - 1];
  int k;
  cin >> k;
  while (k--) {
    int a, b;
    cin >> a >> b;
    cout << numbridges[a] + numbridges[b] - 2 * numbridges[lca(a, b)] << "\n";
  }
  return 0;
}
