#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10, LG = 20, INF = 1e9 + 7;
long long par[N][LG + 2], cnt[N], n, m, k, h[N], highest[N], cutedge[N];
vector<int> adj[N];
bool mark[N];
void DFS(int v, int parent, int t) {
  mark[v] = 1;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i];
    if (mark[u]) {
      if (u != parent && t) highest[v] = min(h[u], highest[v]);
      continue;
    }
    if (t) {
      h[u] = h[v] + 1;
      par[u][0] = v;
    } else
      cutedge[u] += cutedge[v];
    DFS(u, v, t);
    if (t) highest[v] = min(highest[v], highest[u]);
  }
  if (highest[v] >= h[v] && t) cutedge[v]++;
}
long long LCA(int a, int b) {
  if (h[a] < h[b]) swap(a, b);
  for (int i = LG; i >= 0; i--)
    if (h[par[a][i]] >= h[b]) a = par[a][i];
  if (a == b) return a;
  for (int i = LG; 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_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  memset(highest, INF, sizeof highest);
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  h[0] = -1;
  DFS(1, 0, 1);
  memset(mark, 0, sizeof mark);
  DFS(1, 0, 0);
  for (int j = 1; j <= LG; j++)
    for (int i = 1; i <= n; i++) par[i][j] = par[par[i][j - 1]][j - 1];
  cin >> k;
  while (k--) {
    int x, y;
    cin >> x >> y;
    int lca = LCA(x, y);
    cout << cutedge[x] + cutedge[y] - 2 * cutedge[lca] << endl;
  }
}
