#include <bits/stdc++.h>
int adjL[201][210];
int visited[201];
int broken[201][201];
int edge[200][2];
int R[200][2];
int fine[201];
int dfs(int v, int c) {
  int i;
  int a;
  visited[v] = c;
  for (i = 1; i <= adjL[v][0]; i++) {
    a = adjL[v][i];
    if (visited[a] != 0 || broken[v][a]) continue;
    dfs(a, c);
  }
  return 0;
}
int dfs_loop(int n) {
  int i, j;
  int c;
  for (i = 1; i <= n; i++) visited[i] = 0;
  c = 1;
  for (i = 1; i <= n; i++)
    if (visited[i] == 0) {
      dfs(i, c);
      c++;
    }
  return 0;
}
int main() {
  int n, m, k;
  int i, j;
  int a, b;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) {
    scanf("%d%d", &a, &b);
    adjL[a][++adjL[a][0]] = b;
    adjL[b][++adjL[b][0]] = a;
    edge[i][0] = a;
    edge[i][1] = b;
  }
  scanf("%d", &k);
  for (i = 0; i < k; i++) scanf("%d%d", &R[i][0], &R[i][1]);
  for (i = 1; i <= n; i++) fine[i] = 0;
  for (i = 0; i < m; i++) {
    a = edge[i][0];
    b = edge[i][1];
    broken[a][b] = broken[b][a] = 1;
    dfs_loop(n);
    broken[a][b] = broken[b][a] = 0;
    for (j = 0; j < k; j++)
      if (visited[R[j][0]] != visited[R[j][1]]) fine[j + 1]++;
  }
  for (i = 1; i <= k; i++) printf("%d\n", fine[i]);
  return 0;
}
