#include <bits/stdc++.h>
using namespace std;
int n, m, k, h[256], b[512], e[512], z = 2, q[256];
void go(int x, int y) {
  int s = 0;
  for (int i = 2; i < z; i += 2) {
    int v[256] = {0}, d = 0, t = 0;
    v[q[t++] = x] = 1;
    while (d < t && !v[y]) {
      int a = q[d++];
      for (int j = h[a]; j > 0; j = e[j])
        if (j / 2 * 2 != i && !v[b[j]]) v[q[t++] = b[j]] = 1;
    }
    if (!v[y]) ++s;
  }
  cout << s << endl;
}
int main() {
  cin >> n >> m;
  for (int i = 0, x, y; i < m && cin >> x >> y; ++i)
    b[z] = y, e[z] = h[x], h[x] = z++, b[z] = x, e[z] = h[y], h[y] = z++;
  cin >> k;
  for (int i = 0, x, y; i < k && cin >> x >> y; ++i) go(x, y);
}
