#include <bits/stdc++.h>
using namespace std;
const int N = 6e5 + 10;
int n, m, q;
struct Edge {
  int to, next;
} e[N];
int cnt, head[N];
void addedge(int u, int v) {
  e[cnt].to = v;
  e[cnt].next = head[u];
  head[u] = cnt++;
}
int sz, dfn[N], low[N], vis[N], rht[N];
long long sum[N];
stack<int> sta;
void tarjan(int u) {
  dfn[u] = low[u] = ++sz;
  vis[u] = 1;
  sta.push(u);
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].to;
    if (!dfn[v]) {
      tarjan(v);
      low[u] = min(low[u], low[v]);
    } else if (vis[v] && low[u] > dfn[v]) {
      low[u] = dfn[v];
    }
  }
  if (low[u] == dfn[u]) {
    int mn = 9999999, mx = 0;
    while (1) {
      int id = sta.top();
      sta.pop();
      mn = min(mn, id);
      mx = max(mx, id);
      vis[id] = 0;
      if (id == u) break;
    }
    if (mn != mx) rht[mn] = mx - 1;
  }
}
void dfs(int u, int fa) {
  sta.push(u);
  vis[u] = 1;
  for (int i = head[u]; ~i; i = e[i].next) {
    int v = e[i].to;
    if (v != fa) {
      if (!vis[v])
        dfs(v, u);
      else if (vis[v] == 1) {
        int Max = u, Min = u;
        while (!sta.empty()) {
          int w = sta.top();
          sta.pop();
          Max = max(Max, w);
          Min = min(Min, w);
          if (w == v) break;
        }
        rht[Min] = Max - 1;
      }
    }
  }
  if (!sta.empty() && sta.top() == u) sta.pop();
  vis[u] = 2;
}
int main() {
  cin >> n >> m;
  cnt = sz = 0;
  memset(head, -1, sizeof head);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    addedge(u, v);
    addedge(v, u);
  }
  for (int i = 1; i <= n + 1; i++) {
    rht[i] = n;
  }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) dfs(i, -i);
  }
  for (int i = n; i >= 1; i--) {
    rht[i] = min(rht[i], rht[i + 1]);
    sum[i] = sum[i + 1] + rht[i] - i + 1;
  }
  cin >> q;
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    int x = lower_bound(rht + l, rht + r + 1, r) - rht;
    cout << 1LL * (r - x + 1) * (r - x + 2) / 2 + sum[l] - sum[x] << endl;
  }
  return 0;
}
