#include <bits/stdc++.h>
using namespace std;
inline void pisz(int n) { printf("%d\n", n); }
template <typename T, typename TT>
ostream &operator<<(ostream &s, pair<T, TT> t) {
  return s << "(" << t.first << "," << t.second << ")";
}
template <typename T>
ostream &operator<<(ostream &s, vector<T> t) {
  for (int(i) = 0; (i) < (((int)(t.size()))); ++(i)) s << t[i] << " ";
  return s;
}
template <int N, int LOGN>
struct LCA {
  int n, root, pos[N], anc[LOGN + 1][N], *ojc;
  int getPos(int u) {
    if (pos[u] == -1) pos[u] = getPos(ojc[u]) + 1;
    return pos[u];
  }
  LCA(int _n, int _root, int *_ojc) : n(_n), root(_root), ojc(_ojc) {
    for (int(i) = 1; (i) <= (n); ++(i)) anc[0][i] = ojc[i];
    for (int(i) = 1; (i) <= (n); ++(i)) pos[i] = -1;
    pos[root] = 0;
    for (int(i) = 1; (i) <= (n); ++(i))
      if (pos[i] == -1) getPos(i);
    for (int(i) = 1; (i) <= (LOGN); ++(i))
      for (int(j) = 1; (j) <= (n); ++(j)) anc[i][j] = anc[i - 1][anc[i - 1][j]];
  }
  int operator()(int u, int v) {
    if (pos[u] < pos[v]) swap(u, v);
    int diff = pos[u] - pos[v];
    for (int(k) = (LOGN); (k) >= (0); --k)
      if ((1 << k) <= diff) {
        diff -= 1 << k;
        u = anc[k][u];
      }
    if (u == v) return u;
    for (int(k) = (LOGN); (k) >= (0); --k)
      if (anc[k][u] != anc[k][v]) {
        u = anc[k][u];
        v = anc[k][v];
      }
    return ojc[u];
  }
};
struct UnionFind {
  vector<int> tab, ile;
  UnionFind(int n) : tab(n), ile(n, 1) {
    for (int(i) = 0; (i) < (n); ++(i)) tab[i] = i;
  }
  int find(int a) {
    if (tab[a] == a) return a;
    return a = find(tab[a]);
  }
  bool unia(int a, int b) {
    a = find(a), b = find(b);
    if (a == b) return 0;
    if (ile[a] <= ile[b]) {
      ile[b] += ile[a];
      tab[a] = b;
    } else {
      ile[a] += ile[b];
      tab[b] = a;
    }
    return 1;
  }
};
int n;
vector<int> adja[100007];
vector<pair<int, int> > mosty;
bool art[100007];
int czas, wej[100007];
int bridgeArtGo(int v, int p) {
  int k = wej[v] = ++czas;
  for (typeof(adja[v].begin()) it = adja[v].begin(); it != adja[v].end(); it++)
    if (*it != p) k = min(k, wej[*it] ? wej[*it] : bridgeArtGo(*it, v));
  if (wej[p] <= k) art[p] = 1;
  if (wej[p] < k) mosty.push_back(make_pair(min(v, p), max(v, p)));
  return k;
}
void bridgeArt() {
  mosty.clear();
  czas = 0;
  for (int(i) = 1; (i) <= (n); ++(i)) wej[i] = art[i] = 0;
  for (int(i) = 1; (i) <= (n); ++(i))
    if (!wej[i]) {
      wej[i] = ++czas;
      int c = 0;
      for (typeof(adja[i].begin()) it = adja[i].begin(); it != adja[i].end();
           it++)
        if (!wej[*it]) {
          c++;
          bridgeArtGo(*it, i);
        }
      art[i] = (c > 1);
    }
}
vector<int> adj[100007];
int ojciec[100007], glebokosc[100007], renumber[100007];
void dfs(int v, int p, int d) {
  ojciec[v] = p;
  glebokosc[v] = d;
  for (typeof(adj[v].begin()) x = adj[v].begin(); x != adj[v].end(); x++)
    if (*x != p) dfs(*x, v, d + 1);
}
int main() {
  scanf("%d", &n);
  int(m);
  scanf("%d", &(m));
  while (m--) {
    int(a), (b);
    scanf("%d %d", &(a), &(b));
    adja[a].push_back(b);
    adja[b].push_back(a);
  }
  bridgeArt();
  UnionFind uf(n + 1);
  set<pair<int, int> > smosty(mosty.begin(), mosty.end());
  for (int(i) = 1; (i) <= (n); ++(i))
    for (typeof(adja[i].begin()) j = adja[i].begin(); j != adja[i].end(); j++) {
      if (!((smosty).find((make_pair(min(i, *j), max(i, *j)))) !=
            (smosty).end()))
        uf.unia(i, *j);
    }
  int next = 1;
  for (int(i) = 1; (i) <= (n); ++(i))
    if (i == uf.find(i)) renumber[i] = next++;
  for (typeof(mosty.begin()) x = mosty.begin(); x != mosty.end(); x++) {
    int a = renumber[uf.find(x->first)], b = renumber[uf.find(x->second)];
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  dfs(1, -1, 0);
  LCA<100007, 17> lca(next - 1, 1, ojciec);
  int(testow);
  scanf("%d", &(testow));
  while (testow--) {
    int(v), (w);
    scanf("%d %d", &(v), &(w));
    v = renumber[uf.find(v)];
    w = renumber[uf.find(w)];
    int lc = lca(v, w);
    pisz(glebokosc[v] + glebokosc[w] - 2 * glebokosc[lc]);
  }
}
