#include <bits/stdc++.h>
using namespace std;
template <class T>
inline T min(T &a, T &b) {
  return a < b ? a : b;
}
template <class T>
inline T max(T &a, T &b) {
  return a > b ? a : b;
}
template <class T>
void read(T &x) {
  char ch;
  while ((ch = getchar()) && !isdigit(ch))
    ;
  x = ch - '0';
  while ((ch = getchar()) && isdigit(ch)) x = x * 10 + ch - '0';
}
struct point {
  int x, y;
  point() {}
  point(int _x, int _y) : x(_x), y(_y) {}
};
const int N = 120000;
vector<int> E[N];
int dfn[N], low[N], n, m, val[N], dep[N], ti, F[N], f[N][23], ok[N];
void dfs(int x) {
  dfn[x] = low[x] = ++ti;
  F[x] = 1;
  for (int i = 0; i < E[x].size(); i++)
    if (!dfn[E[x][i]]) {
      f[E[x][i]][0] = x;
      dfs(E[x][i]);
      low[x] = min(low[x], low[E[x][i]]);
      if (dfn[x] < low[E[x][i]]) ok[E[x][i]] = 1;
    } else if (E[x][i] != f[x][0])
      low[x] = min(low[x], dfn[E[x][i]]);
}
void Dfs(int x, int c) {
  dfn[x] = ++ti;
  val[x] = c + ok[x];
  for (int i = 0; i < E[x].size(); i++)
    if (!dfn[E[x][i]]) dep[E[x][i]] = dep[x] + 1, Dfs(E[x][i], val[x]);
}
void dp() {
  for (int j = 1; j <= 20; j++)
    for (int i = 1; i <= n; i++) f[i][j] = f[f[i][j - 1]][j - 1];
}
int lca(int x, int y) {
  if (dep[x] < dep[y]) swap(x, y);
  for (int i = 20; i >= 0; i--)
    if (dep[f[x][i]] >= dep[y]) x = f[x][i];
  if (x == y) return x;
  for (int i = 20; i >= 0; i--)
    if (f[x][i] != f[y][i]) x = f[x][i], y = f[y][i];
  return f[x][0];
}
int main() {
  scanf("%d%d", &n, &m);
  int x, y;
  for (int i = 1; i <= m; i++)
    scanf("%d%d", &x, &y), E[x].push_back(y), E[y].push_back(x);
  dfs(1);
  memset(dfn, 0, sizeof(dfn));
  ;
  dep[1] = 1;
  Dfs(1, 0);
  dp();
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    int z = lca(x, y);
    printf("%d\n", val[x] + val[y] - val[z] * 2);
  }
}
