#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 300005;
vector<long long> a[MAXN];
long long parent[MAXN], dfn[MAXN], sum[MAXN], mx[MAXN];
bool check[MAXN];
vector<pair<long long, long long> > segment;
long long timer = 0;
pair<long long, long long> find_cycle(long long start, long long end) {
  long long maxi = start, mini = start;
  while (start != end) {
    start = parent[start];
    maxi = max(maxi, start);
    mini = min(mini, start);
  }
  return {mini, maxi};
}
void dfs(long long node) {
  check[node] = true;
  dfn[node] = ++timer;
  for (long long next : a[node]) {
    if (!check[next]) {
      parent[next] = node;
      dfs(next);
    } else if (next != parent[node] && dfn[node] > dfn[next]) {
      auto p = find_cycle(node, next);
      segment.push_back(p);
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  for (long long i = 1; i <= n; i++) {
    if (!check[i]) dfs(i);
  }
  fill(mx + 1, mx + 1 + n, n);
  for (long long i = 0; i < segment.size(); i++) {
    auto p = segment[i];
    mx[p.first] = p.second - 1;
  }
  for (long long i = n - 1; i >= 1; i--) mx[i] = min(mx[i], mx[i + 1]);
  for (long long i = 1; i <= n; i++) sum[i] = sum[i - 1] + mx[i];
  long long q;
  cin >> q;
  for (long long qq = 0; qq < q; qq++) {
    long long s, e;
    cin >> s >> e;
    long long left = s, right = e, mid, idx = s - 1;
    while (left <= right) {
      long long mid = (left + right) >> 1;
      if (mx[mid] <= e) {
        idx = mid;
        left = mid + 1;
      } else {
        right = mid - 1;
      }
    }
    long long sum1 = sum[idx] - sum[s - 1] + e * (e - idx);
    long long sum2 = (s + e) * (e - s + 1) / 2 - (e - s + 1);
    cout << sum1 - sum2 << "\n";
  }
  return 0;
}
