#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T checkmin(T &a, T b) {
  return (a < b) ? a : a = b;
}
template <class T>
inline T checkmax(T &a, T b) {
  return (a > b) ? a : a = b;
}
template <class T>
T GCD(T a, T b) {
  if (a < 0) return GCD(-a, b);
  if (b < 0) return GCD(a, -b);
  return (a == 0) ? b : GCD(b % a, a);
}
template <class T>
T LCM(T a, T b) {
  if (a < 0) return LCM(-a, b);
  if (b < 0) return LCM(a, -b);
  return (a == 0 || b == 0) ? 0 : a / GCD(a, b) * b;
}
namespace Poor {
const int MaxiN = 100005;
const int LogMaxiN = 18;
int N, M, K;
int Depth[MaxiN], Low[MaxiN], Count[MaxiN];
int Pa[MaxiN][LogMaxiN];
bool Vis[MaxiN];
vector<int> Adj[MaxiN];
void DFS(int Cur) {
  Vis[Cur] = 1;
  for (int k = 1; (1 << k) <= Depth[Cur]; ++k)
    Pa[Cur][k] = Pa[Pa[Cur][k - 1]][k - 1];
  Low[Cur] = Depth[Cur];
  for (typeof(Adj[Cur].begin()) it = Adj[Cur].begin(); it != Adj[Cur].end();
       ++it) {
    if (!Vis[*it]) {
      Pa[*it][0] = Cur;
      Depth[*it] = Depth[Cur] + 1;
      DFS(*it);
      Count[*it] = (Low[*it] >= Depth[*it]);
      checkmin(Low[Cur], Low[*it]);
    } else {
      if (*it != Pa[Cur][0]) checkmin(Low[Cur], Depth[*it]);
    }
  }
}
void DFS2(int Cur) {
  for (typeof(Adj[Cur].begin()) it = Adj[Cur].begin(); it != Adj[Cur].end();
       ++it)
    if (Pa[*it][0] == Cur) {
      Count[*it] += Count[Cur];
      DFS2(*it);
    }
}
int LCA(int U, int V) {
  if (Depth[U] < Depth[V]) swap(U, V);
  for (int k = LogMaxiN - 1; k >= 0; --k)
    if (Depth[U] - (1 << k) >= Depth[V]) U = Pa[U][k];
  if (U == V) return U;
  for (int k = LogMaxiN - 1; k >= 0; --k)
    if (Pa[U][k] != Pa[V][k]) U = Pa[U][k], V = Pa[V][k];
  return Pa[U][0];
}
void Run() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; ++i) {
    int U, V;
    scanf("%d%d", &U, &V);
    --U, --V;
    Adj[U].push_back(V);
    Adj[V].push_back(U);
  }
  fill(Vis, Vis + N, 0);
  DFS(0);
  Count[0] = 0;
  DFS2(0);
  scanf("%d", &K);
  for (int i = 0; i < K; ++i) {
    int U, V;
    scanf("%d%d", &U, &V);
    --U, --V;
    int W = LCA(U, V);
    printf("%d\n", Count[U] + Count[V] - Count[W] * 2);
  }
}
}  // namespace Poor
int main() {
  Poor::Run();
  return 0;
}
