#include <bits/stdc++.h>
using namespace std;
int n, m, q, did, eid;
int head[111111], qhead[111111], ver[444444], nxt[444444], wt[444444];
int low[111111], dfn[111111], faeid[111111], fapt[111111], vis[111111];
int setfa[111111];
int X[111111], Y[111111], lca[111111];
int iscutpt[444444];
void init() {
  did = eid = 0;
  memset(head, -1, sizeof(head));
  memset(qhead, -1, sizeof(qhead));
  memset(dfn, 0, sizeof(dfn));
  memset(low, 0, sizeof(low));
  memset(iscutpt, 0, sizeof(iscutpt));
  memset(vis, 0, sizeof(vis));
}
void adde(int u, int v, int w) {
  ver[++eid] = v;
  wt[eid] = w;
  nxt[eid] = head[u];
  head[u] = eid;
}
void addq(int u, int v, int qid) {
  ver[++eid] = v;
  wt[eid] = qid;
  nxt[eid] = qhead[u];
  qhead[u] = eid;
}
void tarjan(int u, int fa) {
  low[u] = dfn[u] = ++did;
  for (int i = head[u]; ~i; i = nxt[i]) {
    int v = ver[i];
    if (v == fa) continue;
    if (!dfn[v]) {
      faeid[v] = i;
      fapt[v] = u;
      tarjan(v, u);
      low[u] = min(low[u], low[v]);
    } else {
      low[u] = min(low[u], dfn[v]);
    }
  }
  for (int i = head[u]; ~i; i = nxt[i]) {
    int v = ver[i];
    if (v == fa) continue;
    if (low[v] > dfn[u]) iscutpt[v] = 1;
  }
}
void setinit() {
  for (int i = 0; i < 111111; ++i) setfa[i] = i;
}
int setfind(int x) {
  if (setfa[x] != x)
    return (setfa[x] = setfind(setfa[x]));
  else
    return x;
}
void setunion(int u, int v) {
  int x = setfind(u);
  int y = setfind(v);
  if (x != y) {
    setfa[y] = x;
  }
}
void dfs(int u, int fa) {
  for (int i = head[u]; ~i; i = nxt[i]) {
    int v = ver[i];
    if (faeid[v] != i) continue;
    iscutpt[v] += iscutpt[u];
    dfs(v, u);
    setfa[v] = u;
  }
  vis[u] = 1;
  for (int i = qhead[u]; ~i; i = nxt[i]) {
    int v = ver[i];
    if (vis[v]) {
      lca[wt[i]] = setfind(v);
    }
  }
}
int main() {
  int u, v, w;
  while (~scanf("%d%d", &n, &m)) {
    init();
    for (int i = 1; i <= m; ++i) {
      scanf("%d%d", &u, &v);
      adde(u, v, 0);
      adde(v, u, 0);
    }
    scanf("%d", &q);
    for (int i = 1; i <= q; ++i) {
      scanf("%d%d", &u, &v);
      X[i] = u, Y[i] = v;
      addq(u, v, i);
      addq(v, u, i);
    }
    tarjan(1, -1);
    setinit();
    dfs(1, -1);
    for (int i = 1; i <= q; ++i)
      printf("%d\n", iscutpt[X[i]] + iscutpt[Y[i]] - 2 * iscutpt[lca[i]]);
  }
  return 0;
}
