#include <bits/stdc++.h>
using namespace std;
const int SIZE = 100009;
vector<pair<int, bool> > adj[SIZE];
int N, M, K;
int ss[SIZE], ls[SIZE], cs[SIZE];
int ps[SIZE];
int ps2[SIZE];
vector<pair<int, int> > qs[SIZE];
int p(int n) {
  if (ps[n] < 0)
    return n;
  else
    return ps[n] = p(ps[n]);
}
void comb(int a, int b) {
  int pa = p(a), pb = p(b);
  if (pa != pb)
    if (ps[pa] < ps[pb])
      ps[pb] = pa;
    else {
      if (ps[pa] == ps[pb]) ps[pb]--;
      ps[pa] = pb;
    }
}
int low[SIZE];
int num[SIZE];
int now;
int table[SIZE];
void go2(int n, int pp, int alc) {
  num[n] = 0;
  table[n] = alc;
  for (int i = 0; i < adj[n].size(); i++)
    if (adj[n][i].first != pp && num[adj[n][i].first])
      go2(adj[n][i].first, n, alc + adj[n][i].second);
}
int go(int n, int pp) {
  num[n] = low[n] = ++now;
  ps2[p(n)] = n;
  for (int i = 0; i < qs[n].size(); i++)
    if (num[qs[n][i].first]) cs[qs[n][i].second] = ps2[p(qs[n][i].first)];
  for (int i = 0; i < adj[n].size(); i++)
    if (adj[n][i].first != pp) {
      if (!num[adj[n][i].first])
        low[n] = min(low[n], go(adj[n][i].first, n));
      else
        low[n] = min(low[n], low[adj[n][i].first]);
      comb(n, adj[n][i].first);
      ps2[p(adj[n][i].first)] = n;
    }
  for (int i = 0; i < adj[n].size(); i++)
    if (adj[n][i].first != pp && low[adj[n][i].first] > num[n])
      adj[n][i].second = true;
  return low[n];
}
int main() {
  scanf("%d%d", &N, &M);
  memset(ps, -1, sizeof(ps));
  while (M--) {
    int a, b;
    scanf("%d%d", &a, &b);
    adj[a].push_back(make_pair(b, false));
    adj[b].push_back(make_pair(a, false));
  }
  scanf("%d", &K);
  for (int i = 0; i < K; i++) {
    scanf("%d%d", ss + i, ls + i);
    qs[ss[i]].push_back(pair<int, int>(ls[i], i));
    qs[ls[i]].push_back(pair<int, int>(ss[i], i));
  }
  go(1, -1);
  go2(1, -1, 0);
  for (int i = 0; i < K; i++)
    printf("%d\n", table[ls[i]] + table[ss[i]] - 2 * table[cs[i]]);
  return 0;
}
