#include <bits/stdc++.h>
using namespace std;
int dx[] = {-1, 1, 0, 0, 0, 0, 0, 0};
int dy[] = {0, 0, 1, -1, 0, 0, 0, 0};
const long long inf = 100000007;
const double eps = 0.000000009;
long long mod = 1000000007;
long long n, m;
int a[205][205];
vector<vector<int> > a1;
vector<int> visited;
int to, from;
int dfs(int node) {
  if (node == to) return 1;
  visited[node] = 1;
  int ans = 0;
  vector<int> x = a1[node];
  for (int i = 0; i < x.size(); i++) {
    if (!visited[x[i]] && a[node][x[i]]) ans = ans | dfs(x[i]);
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  vector<pair<int, int> > edges;
  for (int i = 0; i < n; i++) {
    vector<int> x;
    a1.push_back(x);
  }
  memset(a, 0, sizeof(a));
  for (int i = 0; i < m; i++) {
    int t1, t2;
    cin >> t1 >> t2;
    t1--;
    t2--;
    a[t1][t2] = a[t2][t1] = 1;
    a1[t1].push_back(t2);
    a1[t2].push_back(t1);
    edges.push_back(pair<int, int>(t1, t2));
  }
  int t;
  cin >> t;
  while (t--) {
    int t1, t2;
    cin >> t1 >> t2;
    t1--;
    t2--;
    from = t1;
    to = t2;
    long long ans = 0;
    for (int i = 0; i < edges.size(); i++) {
      a[edges[i].first][edges[i].second] = a[edges[i].second][edges[i].first] =
          0;
      visited.assign(n, 0);
      ans += dfs(from);
      a[edges[i].first][edges[i].second] = a[edges[i].second][edges[i].first] =
          1;
    }
    cout << edges.size() - ans << endl;
  }
  return 0;
}
