#include <bits/stdc++.h>
using namespace std;
vector<vector<int> > adj;
vector<pair<int, int> > Bridges;
int low[10000];
int num[10000];
int idx;
void dfs_Bridges(int u, int p = -1) {
  num[u] = low[u] = idx++;
  for (int i = 0; i < adj[u].size(); ++i) {
    int v = adj[u][i];
    if (v == p) continue;
    if (num[v] == -1) {
      dfs_Bridges(v, u);
      if (low[v] > num[u]) Bridges.push_back(pair<int, int>(u, v));
      low[u] = min(low[u], low[v]);
    } else
      low[u] = min(low[u], num[v]);
  }
}
void buildBridges(int N) {
  idx = 0;
  Bridges = vector<pair<int, int> >();
  memset(num, -1, sizeof(num));
  for (int i = 0; i < N; ++i)
    if (num[i] == -1) dfs_Bridges(i);
}
set<pair<int, int> > B_SET;
bool isBridge(pair<int, int> p) { return B_SET.count(p) > 0; }
int P[100010], L[100000];
vector<vector<int> > adj2;
vector<vector<int> > list_of_nodes;
bool vis[100010];
void tree_dfs(int u, int idx = 0, int lvl = 0) {
  list_of_nodes[idx].push_back(u);
  vis[u] = true;
  L[idx] = lvl;
  for (int i = 0; i < adj[u].size(); ++i) {
    int v = adj[u][i];
    if (vis[v]) continue;
    if (isBridge(pair<int, int>(u, v)) || isBridge(pair<int, int>(v, u))) {
      list_of_nodes.push_back(vector<int>());
      adj2.push_back(vector<int>());
      adj2.back().push_back(idx);
      adj2[idx].push_back(adj2.size() - 1);
      P[adj2.size() - 1] = idx;
      tree_dfs(v, list_of_nodes.size() - 1, lvl + 1);
    } else {
      tree_dfs(v, idx, lvl);
    }
  }
}
int G[100010];
int T[100000][20];
void create(int *P, int N) {
  memset(T, -1, sizeof(T));
  for (int i = 0; i < N; ++i) T[i][0] = P[i];
  for (int lvl = 1; (1 << lvl) <= N; lvl++)
    for (int i = 0; i < N; ++i)
      if (T[i][lvl - 1] != -1) T[i][lvl] = T[T[i][lvl - 1]][lvl - 1];
}
int LCA(int x, int y) {
  if (L[x] < L[y]) swap(x, y);
  int log = 0;
  for (log = 1; (1 << log) <= L[x]; log++)
    ;
  log--;
  for (int i = log; L[x] != L[y]; i--)
    if (L[x] - (1 << i) >= L[y]) x = T[x][i];
  for (int i = log; x != y && i >= 0; i--)
    if (T[x][i] != T[y][i]) x = T[x][i], y = T[y][i];
  return x == y ? x : T[x][0];
}
int main() {
  cin.sync_with_stdio(false);
  int N, M, K;
  cin >> N >> M;
  adj = vector<vector<int> >(N);
  for (int i = 0; i < M; ++i) {
    int u, v;
    cin >> u >> v;
    adj[u - 1].push_back(v - 1);
    adj[v - 1].push_back(u - 1);
  }
  buildBridges(N);
  for (int i = 0; i < Bridges.size(); ++i) B_SET.insert(Bridges[i]);
  list_of_nodes = vector<vector<int> >(1);
  adj2 = vector<vector<int> >(1);
  memset(vis, 0, sizeof(vis));
  memset(P, -1, sizeof(P));
  tree_dfs(0);
  for (int i = 0; i < list_of_nodes.size(); ++i)
    for (int j = 0; j < list_of_nodes[i].size(); ++j)
      G[list_of_nodes[i][j]] = i;
  create(P, adj2.size());
  cin >> K;
  for (int i = 0; i < K; ++i) {
    int u, v;
    cin >> u >> v;
    int s = G[u - 1], e = G[v - 1];
    int lc = LCA(s, e);
    cout << L[s] - L[lc] + L[e] - L[lc] << endl;
  }
  return 0;
}
