#include <bits/stdc++.h>
using namespace std;
const int MaxN = 110000, MaxM = 110000, MaxK = 110000, MaxE = MaxM * 2,
          MaxV = MaxN;
int n, m, q;
int Next[MaxE], u[MaxE], v[MaxE], Head[MaxV], ENum, Lab[MaxV], Low[MaxV], Total,
    Bridge[MaxE], BTotal;
bool Flag[MaxE], View[MaxV];
int NEXT[MaxE], U[MaxE], V[MaxE], HEAD[MaxV], ENUM, Depth[MaxV];
int s[MaxE][20], Len, Pos[MaxV];
inline void AddEdge(const int x, const int y) {
  Next[++ENum] = Head[x];
  v[Head[x] = ENum] = y;
  u[ENum] = x;
  Next[MaxE - ENum] = Head[y];
  v[Head[y] = MaxE - ENum] = x;
  u[MaxE - ENum] = y;
}
inline void ADDEDGE(const int x, const int y) {
  NEXT[++ENUM] = HEAD[x];
  V[HEAD[x] = ENUM] = y;
}
void Init() {
  scanf("%d%d", &n, &m);
  for (int i = 1, x, y; i <= m; ++i) {
    scanf("%d%d", &x, &y);
    AddEdge(x, y);
  }
  scanf("%d", &q);
}
void DFS(const int t, const int f) {
  Lab[t] = Low[t] = ++Total;
  for (int i = Head[t]; i; i = Next[i]) {
    if (!Lab[v[i]]) {
      DFS(v[i], t);
      Low[t] = min(Low[t], Low[v[i]]);
    } else if (v[i] != f)
      Low[t] = min(Low[t], Lab[v[i]]);
    if (Low[v[i]] > Lab[t]) {
      Bridge[++BTotal] = i;
      Flag[i] = Flag[MaxE - i] = 1;
    }
  }
}
void Color(const int t) {
  Lab[t] = Total;
  for (int i = Head[t]; i; i = Next[i])
    if (!Flag[i] && !Lab[v[i]]) Color(v[i]);
}
void DFS2(const int t) {
  View[t] = 1;
  s[Pos[t] = ++Len][0] = t;
  for (int i = HEAD[t]; i; i = NEXT[i])
    if (!View[V[i]]) {
      Depth[V[i]] = Depth[t] + 1;
      DFS2(V[i]);
      s[++Len][0] = t;
    }
}
inline int RMQMin(const int x, const int y) {
  return Depth[x] < Depth[y] ? x : y;
}
void Initialize() {
  DFS2(1);
  for (int j = 1; 1 << j <= Len; ++j)
    for (int i = 1; i + (1 << j) - 1 <= Len; ++i)
      s[i][j] = RMQMin(s[i][j - 1], s[i + (1 << j - 1)][j - 1]);
}
int LCA(int x, int y) {
  if ((x = Pos[x]) > (y = Pos[y])) swap(x, y);
  const int k = (int)log2(y - x + 1);
  return RMQMin(s[x][k], s[y - (1 << k) + 1][k]);
}
int main() {
  Init();
  DFS(1, 0);
  memset(Lab, 0, sizeof(Lab));
  Total = 0;
  for (int i = 1; i <= n; ++i)
    if (!Lab[i]) {
      ++Total;
      Color(i);
    }
  for (int i = 1; i <= BTotal; ++i) {
    ADDEDGE(Lab[u[Bridge[i]]], Lab[v[Bridge[i]]]);
    ADDEDGE(Lab[v[Bridge[i]]], Lab[u[Bridge[i]]]);
  }
  Initialize();
  for (int x, y, z; q; --q) {
    scanf("%d%d", &x, &y);
    z = LCA(x = Lab[x], y = Lab[y]);
    printf("%d\n", Depth[x] + Depth[y] - Depth[z] * 2);
  }
  return 0;
}
