#include <bits/stdc++.h>
using namespace std;
vector<int> Graph[350];
int low[350], num[350], ct;
int dp[350][350];
bool visited[350];
int dfs(int v, int parent = -1) {
  low[v] = num[v] = ct++;
  for (int i = 0; i < (int)Graph[v].size(); i++) {
    int node = Graph[v][i];
    if (!visited[node]) {
      visited[node] = true;
      int numb = dfs(node, v);
      if (numb > num[v]) {
        dp[v][node] = dp[node][v] = 1;
      } else
        low[v] = min(low[v], low[node]);
    } else if (parent != node)
      low[v] = min(low[v], num[node]);
  }
  return low[v];
}
bool vst[350];
int prt[350];
void create(int node) {
  vst[node] = true;
  queue<int> P;
  P.push(node);
  while (!P.empty()) {
    int k = P.front();
    P.pop();
    int tm = Graph[k].size();
    for (int i = 0; i < tm; i++) {
      int no = Graph[k][i];
      if (!vst[no]) {
        vst[no] = true;
        P.push(no);
        prt[no] = k;
      }
    }
  }
}
int solve(int fim, int ini, int parent) {
  if (fim == -1) return 0;
  int cur = dp[parent][fim];
  if (fim == ini) return cur;
  return cur + solve(prt[fim], ini, fim);
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }
  for (int i = 0; i <= n; i++) visited[i] = false;
  ct = 0;
  visited[1] = true;
  dfs(1);
  int k;
  scanf("%d", &k);
  for (int i = 0; i < k; i++) {
    int ini, fim;
    scanf("%d %d", &ini, &fim);
    memset(prt, -1, sizeof(prt));
    memset(vst, false, sizeof(vst));
    create(ini);
    printf("%d\n", solve(fim, ini, 0));
  }
  return 0;
}
