#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T _min(T A, T B) {
  return A < B ? A : B;
}
template <typename T>
inline T _max(T A, T B) {
  return A > B ? A : B;
}
template <typename T>
inline char MIN(T& A, T B) {
  return A > B ? (A = B, 1) : 0;
}
template <typename T>
inline char MAX(T& A, T B) {
  return A < B ? (A = B, 1) : 0;
}
template <typename T>
inline void _swap(T& A, T& B) {
  A ^= B ^= A ^= B;
}
template <typename T>
inline T read(T& x) {
  x = 0;
  int f = 0;
  char c;
  while (!isdigit(c = getchar()))
    if (c == '-') f = 1;
  while (isdigit(c)) x = x * 10 + (c & 15), c = getchar();
  return f ? x = -x : x;
}
const int N = 3e5 + 7;
struct thxorz {
  int to[N << 1], nxt[N << 1], head[N], tot;
  inline void add(int x, int y) {
    to[++tot] = y, nxt[tot] = head[x], head[x] = tot;
    to[++tot] = x, nxt[tot] = head[y], head[y] = tot;
  }
} G;
long long sum[N];
int n, m, q, L, R, l, r;
int rb[N];
int dfn[N], low[N], tim, stk[N], Top, rt;
void tarjan(int x) {
  dfn[x] = low[x] = ++tim;
  stk[++Top] = x;
  for (register int j = G.head[x]; j; j = G.nxt[j]) {
    if (!dfn[G.to[j]]) {
      tarjan(G.to[j]), MIN(low[x], low[G.to[j]]);
      if (low[G.to[j]] >= dfn[x]) {
        int tmp, mi = n + 1, ma = 0, cnt = 0;
        do MIN(mi, tmp = stk[Top--]), MAX(ma, tmp), ++cnt;
        while (tmp ^ G.to[j]);
        MIN(mi, x), MAX(ma, x), ++cnt;
        if (cnt > 2) MIN(rb[mi], ma);
      }
    } else
      MIN(low[x], dfn[G.to[j]]);
  }
}
int main() {
  read(n), read(m);
  for (register int i = 1, x, y; i <= m; ++i) read(x), read(y), G.add(x, y);
  fill(rb + 1, rb + n + 1, n + 1);
  for (register int i = 1; i <= n; ++i)
    if (!dfn[i]) Top = 0, tarjan(i);
  for (register int i = n - 1; i; --i) MIN(rb[i], rb[i + 1]);
  for (register int i = 1; i <= n; ++i) sum[i] = sum[i - 1] + rb[i];
  read(q);
  for (register int i = 1, L, R, mid; i <= q; ++i) {
    l = read(L), r = read(R);
    --L;
    while (L < R) {
      mid = L + R + 1 >> 1;
      if (rb[mid] <= r)
        L = mid;
      else
        R = mid - 1;
    }
    printf("%I64d\n",
           (r - l + 2) * 1ll * (r - l + 1) / 2 -
               ((L - l + 1) * 1ll * (r + 1) - (sum[L] - sum[l - 1])));
  }
  return 0;
}
