#include <bits/stdc++.h>
using namespace std;
int N, M, Q, cnt;
long long a, b, i;
vector<int> g[1 << 19];
int parent[1 << 19], cycle[1 << 19];
int depth[1 << 19];
long long prefix[1 << 19], sEnd[1 << 19];
pair<long long, long long> cB[1 << 19];
void dfs(int c, int p = -1, int d = 1) {
  parent[c] = p;
  depth[c] = d;
  for (int n : g[c])
    if (n ^ p) {
      if (depth[n] && depth[n] < depth[c]) {
        int k = c;
        ++cnt;
        while (k ^ n) cycle[k] = cnt, k = parent[k];
        cycle[k] = cnt;
      } else if (!depth[n])
        dfs(n, c, d + 1);
    }
}
int search(int k) {
  int l = 0, r = cnt;
  while (l < r) {
    int m = (l + r) / 2;
    if (cB[m].first < k)
      l = m + 1;
    else
      r = m;
  }
  return l;
}
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  for (cin >> N >> M; i < M; ++i) {
    cin >> a >> b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (i = 0; i++ < N;)
    if (!depth[i]) dfs(i);
  fill(cB, cB + cnt, make_pair(1e9, 0));
  for (i = 0; i++ < N;) {
    if (!cycle[i]) continue;
    cB[cycle[i] - 1].first = min(cB[cycle[i] - 1].first, i);
    cB[cycle[i] - 1].second = max(cB[cycle[i] - 1].second, i);
  }
  sort(cB, cB + cnt);
  int l = 1;
  for (i = 1; i < cnt; ++l, ++i) {
    while (l && cB[i].second <= cB[l - 1].second) --l;
    cB[l] = cB[i];
  }
  cnt = cnt ? l : 0;
  for (i = 0; i++ < N;) {
    prefix[i] += prefix[i - 1];
    int p = search(i);
    prefix[i] += (sEnd[i] = (p >= cnt ? N : cB[p].second - 1)) + 1 - i;
  }
  for (cin >> Q; Q--;) {
    cin >> a >> b;
    long long r = upper_bound(sEnd + 1, sEnd + N + 1, b) - 1 - sEnd;
    if (a > r)
      cout << (b - a + 1) * (b - a + 2) / 2 << "\n";
    else
      cout << prefix[r] + (b - r) * (b - r + 1) / 2 - prefix[a - 1] << "\n";
  }
}
