#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int timer, tin[N], l[N], tup[N], tout[N], which[N], tree[N][20];
vector<pair<int, int> > g[N];
bitset<N> not_bridge, vis;
void dfs(int v, int p = 0) {
  tup[v] = tin[v] = ++timer;
  vis[v] = 1;
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i].first;
    int road = g[v][i].second;
    if (to == p) continue;
    if (vis[to]) {
      not_bridge[road] = 1;
      tup[v] = min(tup[v], tin[to]);
    } else {
      dfs(to, v);
      tup[v] = min(tup[v], tup[to]);
      if (tup[to] <= tin[v]) {
        not_bridge[road] = 1;
      }
    }
  }
}
void dfs_1(int v, int now, int p = 0, bool yes = 0) {
  which[v] = now;
  vis[v] = 1;
  if (yes) {
    tin[now] = ++timer;
    tree[now][0] = p;
    l[now] = l[p] + 1;
    for (int i = 1; i < 20; ++i) {
      tree[now][i] = tree[tree[now][i - 1]][i - 1];
    }
  }
  for (int i = 0; i < g[v].size(); ++i) {
    int to = g[v][i].first;
    int road = g[v][i].second;
    if (vis[to]) continue;
    if (not_bridge[road]) {
      dfs_1(to, now, now);
    } else {
      dfs_1(to, to, now, 1);
    }
  }
  if (yes) tout[now] = ++timer;
}
bool upper(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
int lca(int a, int b) {
  if (upper(a, b)) return a;
  if (upper(b, a)) return b;
  for (int i = 19; i >= 0; --i) {
    if (!upper(tree[a][i], b) && tree[a][i] != 0) a = tree[a][i];
  }
  return tree[a][0];
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    g[a].push_back(make_pair(b, i));
    g[b].push_back(make_pair(a, i));
  }
  dfs(1);
  for (int i = 1; i <= n; ++i) vis[i] = 0;
  timer = 0;
  dfs_1(1, 1, 1, 1);
  int mer;
  cin >> mer;
  while (mer--) {
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d\n", l[which[a]] - l[lca(which[a], which[b])] * 2 + l[which[b]]);
  }
  return 0;
}
