#include <bits/stdc++.h>
using namespace std;
const int N = 310000;
vector<int> V[N], adj[N];
int as[N], vis[N], par[N], T;
long long sum[N];
void dfs(int u, int p) {
  vis[u] = ++T, par[u] = p;
  for (int v : adj[u]) {
    if (v == p) continue;
    if (!vis[v])
      dfs(v, u);
    else if (vis[v] < vis[u]) {
      int x = u;
      int L = 1e6, R = 1;
      while (x != v) {
        L = min(L, x);
        R = max(R, x);
        x = par[x];
      }
      assert(x == v);
      L = min(L, v);
      R = max(R, v);
      V[L].push_back(R);
    }
  }
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0);
  as[n + 1] = n + 1;
  for (int i = n; i > 0; i--) {
    as[i] = as[i + 1];
    for (int x : V[i]) as[i] = min(as[i], x);
  }
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + as[i] - i;
  int q;
  scanf("%d", &q);
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    int p = upper_bound(as + l, as + n + 1, r) - as;
    printf("%lld\n",
           sum[p - 1] - sum[l - 1] + (r - p + 1) * 1LL * (r - p + 2) / 2);
  }
  return 0;
}
