#include <bits/stdc++.h>
using namespace std;
int read() {
  char c;
  int s = 0, t = 1;
  while (!isdigit(c = getchar()))
    if (c == '-') t = -1;
  do {
    s = s * 10 + c - '0';
  } while (isdigit(c = getchar()));
  return s * t;
}
const int maxn = 300010;
int tot = 1, first[maxn], low[maxn], dfn[maxn], dfsnum = 0, c[maxn], n, m,
    mins[maxn], maxs[maxn], s[maxn], d[maxn];
long long sum[maxn], ss[maxn];
bool iscut[maxn];
struct edge {
  int v, from;
} e[maxn * 2];
void insert(int u, int v) {
  tot++;
  e[tot].v = v;
  e[tot].from = first[u];
  first[u] = tot;
}
void tarjan(int x, int fa) {
  low[x] = dfn[x] = ++dfsnum;
  for (int i = first[x]; i; i = e[i].from)
    if (e[i].v != fa) {
      if (!dfn[e[i].v]) {
        tarjan(e[i].v, x);
        low[x] = min(low[x], low[e[i].v]);
        if (low[e[i].v] > dfn[x]) iscut[i] = iscut[i ^ 1] = 1;
      } else
        low[x] = min(low[x], dfn[e[i].v]);
    }
}
void dfs(int x, int y) {
  c[x] = y;
  d[y]++;
  for (int i = first[x]; i; i = e[i].from)
    if (!iscut[i] && !c[e[i].v]) dfs(e[i].v, y);
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    int u = read(), v = read();
    insert(u, v);
    insert(v, u);
  }
  tarjan(1, 0);
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    if (!c[i]) dfs(i, ++cnt);
  memset(mins, 0x3f, sizeof(mins));
  for (int i = 1; i <= n; i++) {
    mins[c[i]] = min(mins[c[i]], i);
    maxs[c[i]] = max(maxs[c[i]], i);
  }
  for (int i = 1; i <= n; i++) s[i] = n;
  for (int i = 1; i <= cnt; i++)
    if (d[i] > 1) s[mins[i]] = maxs[i] - 1;
  for (int i = n - 1; i >= 1; i--) s[i] = min(s[i], s[i + 1]);
  for (int i = 1; i <= n; i++)
    sum[i] = sum[i - 1] + (s[i] - i + 1), ss[i] = ss[i - 1] + i;
  int q = read();
  while (q--) {
    int u = read(), v = read();
    int x = lower_bound(s + u, s + v + 1, v) - s;
    long long ans = 0;
    ans += sum[x - 1] - sum[u - 1];
    ans += 1ll * (v - x + 1) * (v - x + 2) / 2;
    printf("%lld\n", ans);
  }
  return 0;
}
