#include <bits/stdc++.h>
using namespace std;
struct edge {
  int n, t;
} e[300010 << 1];
int n, m, Q, cnt, head[300010], ecnt, l[300010], lg[300010], f[300010][19],
    mi[300010][19], mx[300010][19], dep[300010];
long long s[300010];
pair<int, int> a[300010];
bool vis[300010];
inline void add(int a, int b) {
  e[++ecnt] = (edge){head[a], b}, head[a] = ecnt;
}
inline int jump(int x, int d) {
  for (int i = 0; d; d >>= 1, i++)
    if (d & 1) x = f[x][i];
  return x;
}
inline void dfs(int x, int p) {
  vis[x] = 1;
  f[x][0] = p, mi[x][0] = min(x, p), mx[x][0] = max(x, p);
  for (int i = 1; i < 19; i++) f[x][i] = f[f[x][i - 1]][i - 1];
  for (int i = 1; i < 19; i++)
    mi[x][i] = min(mi[x][i - 1], mi[f[x][i - 1]][i - 1]);
  for (int i = 1; i < 19; i++)
    mx[x][i] = max(mx[x][i - 1], mx[f[x][i - 1]][i - 1]);
  for (int i = head[x]; i; i = e[i].n)
    if (!vis[e[i].t])
      dep[e[i].t] = dep[x] + 1, dfs(e[i].t, x), x;
    else if (e[i].t != p && dep[e[i].t] < dep[x]) {
      int t = dep[x] - dep[e[i].t], v = lg[t], y = jump(x, t - (1 << v));
      a[++cnt] = make_pair(min(mi[x][v], mi[y][v]), max(mx[x][v], mx[y][v]));
    }
}
int main() {
  scanf("%d%d", &n, &m);
  while (m--) {
    int a, b;
    scanf("%d%d", &a, &b), add(a, b), add(b, a);
  }
  for (int i = 1, c = 0; i <= n; i++) {
    lg[i] = c;
    if (i >> 1 == 1 << c) c++;
  }
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, i);
  sort(a + 1, a + 1 + cnt);
  int v = n;
  for (int i = n, j = cnt; i; i--) {
    while (j && a[j].first >= i) v = min(v, a[j].second - 1), j--;
    l[i] = v;
  }
  for (int i = 1; i <= n; i++) s[i] = s[i - 1] + l[i] - i + 1;
  cin >> Q;
  while (Q--) {
    int x, y, z;
    scanf("%d%d", &x, &y);
    z = lower_bound(l + x, l + y + 1, y) - l;
    printf("%I64d\n",
           s[z - 1] - s[x - 1] + 1ll * (y - z + 1) * (y - z + 2) / 2);
  }
  return 0;
}
