#include <bits/stdc++.h>
template <class T>
bool chmax(T &a, const T &b) {
  return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  return (b < a) ? (a = b, 1) : 0;
}
using namespace std;
using ll = long long;
const int vmax = 100010;
vector<int> graph[vmax];
int ord[vmax], low[vmax];
vector<int> tree[vmax];
int comp[vmax], visited[vmax];
int parent[vmax][20], depth[vmax];
void dfs(int v, int p, int &k) {
  ord[v] = k++;
  low[v] = ord[v];
  for (auto &v2 : graph[v]) {
    if (v2 == p) continue;
    if (ord[v2] == -1)
      dfs(v2, v, k), chmin(low[v], low[v2]);
    else
      chmin(low[v], ord[v2]);
  }
}
void bfs(int root, int &total) {
  queue<int> q;
  comp[root] = total, q.push(root);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (auto &v2 : graph[v]) {
      if (comp[v2] >= 0) continue;
      bool bridge = ord[v2] < low[v] || ord[v] < low[v2];
      if (bridge) {
        bfs(v2, ++total);
        tree[comp[v]].push_back(comp[v2]);
        tree[comp[v2]].push_back(comp[v]);
      } else {
        comp[v2] = comp[root];
        q.push(v2);
      }
    }
  }
  return;
}
int bridge(int n) {
  int num = 0, total = 0;
  for (int i = int(0); i < int(n); ++i) ord[i] = low[i] = comp[i] = -1;
  for (int i = int(0); i < int(n); ++i)
    if (ord[i] == -1) dfs(i, -1, num);
  for (int i = int(0); i < int(n); ++i)
    if (comp[i] == -1) bfs(i, total);
  return total + 1;
}
void tree_dfs(int v, int p, int d) {
  parent[v][0] = p;
  depth[v] = d;
  for (auto &v2 : tree[v])
    if (v2 != p) tree_dfs(v2, v, d + 1);
};
void init(int n) {
  tree_dfs(0, -1, 0);
  for (int j = int(0); j < int(19); ++j)
    for (int i = int(0); i < int(n); ++i) {
      if (parent[i][j] == -1)
        parent[i][j + 1] = -1;
      else
        parent[i][j + 1] = parent[parent[i][j]][j];
    }
}
int lca(int u, int v) {
  if (depth[u] < depth[v]) swap(u, v);
  for (int i = 19; i >= 0; --i)
    if ((depth[u] - depth[v]) >> i & 1) u = parent[u][i];
  if (u == v) return u;
  for (int i = 19; i >= 0; --i) {
    if (parent[u][i] != parent[v][i]) {
      u = parent[u][i];
      v = parent[v][i];
    }
  }
  return parent[u][0];
}
int main(void) {
  int v, e;
  scanf("%d%d", &v, &e);
  for (int loop = int(0); loop < int(e); ++loop) {
    int a, b;
    scanf("%d%d", &a, &b);
    a--, b--;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }
  int nv = bridge(v);
  init(nv);
  int k;
  scanf("%d", &k);
  for (int loop = int(0); loop < int(k); ++loop) {
    int a, b;
    scanf("%d%d", &a, &b);
    a = comp[a - 1], b = comp[b - 1];
    printf("%d\n", depth[a] + depth[b] - 2 * depth[lca(a, b)]);
  }
  return 0;
}
