#include <bits/stdc++.h>
using namespace std;
const int N = 310000;
int n, m, q;
int head[N], ce;
struct edge {
  int to, nxt;
} e[N << 1];
inline void lnk(int a, int b) { e[++ce] = (edge){b, head[a]}, head[a] = ce; }
int vis[N], fa[N], dep[N];
struct SegmentTree {
  int L[N << 2], R[N << 2], mx[N << 2], nxt[N];
  long long s[N << 2];
  inline void build(int l, int r, int k) {
    L[k] = l, R[k] = r, mx[k] = n + 1;
    if (l == r) {
      nxt[l] = n + 1;
      return;
    }
    int mid = l + r >> 1;
    build(l, mid, k << 1);
    build(mid + 1, r, k << 1 | 1);
  }
  inline void update(int l, int r, int k, int x) {
    if (l <= L[k] && R[k] <= r) {
      mx[k] = min(mx[k], x);
      return;
    }
    int mid = (L[k] + R[k]) >> 1;
    if (l <= mid) update(l, r, k << 1, x);
    if (r > mid) update(l, r, k << 1 | 1, x);
  }
  inline long long Query(int l, int r, int k) {
    if (l <= L[k] && R[k] <= r) return s[k];
    int mid = (L[k] + R[k]) >> 1;
    long long ret = 0;
    if (l <= mid) ret += Query(l, r, k << 1);
    if (r > mid) ret += Query(l, r, k << 1 | 1);
    return ret;
  }
  inline void pushdown(int x) {
    mx[x << 1] = min(mx[x << 1], mx[x]),
            mx[x << 1 | 1] = min(mx[x << 1 | 1], mx[x]);
  }
  inline void pushup(int x) { s[x] = s[x << 1] + s[x << 1 | 1]; }
  inline void Push(int x) {
    if (L[x] == R[x]) {
      nxt[L[x]] = mx[x], s[x] = mx[x] - L[x];
      return;
    }
    pushdown(x);
    Push(x << 1);
    Push(x << 1 | 1);
    pushup(x);
  }
} Tr;
inline void dfs(int u, int lst) {
  vis[u] = 1, fa[u] = lst, dep[u] = dep[lst] + 1;
  for (int i = head[u]; i; i = e[i].nxt) {
    int v = e[i].to;
    if (v == lst) continue;
    if (vis[v]) {
      int cur = u, mn = u, mx = u;
      if (dep[v] > dep[u]) continue;
      while (cur != v) cur = fa[cur], mn = min(mn, cur), mx = max(mx, cur);
      Tr.update(1, mn, 1, mx);
      continue;
    }
    dfs(v, u);
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    lnk(u, v);
    lnk(v, u);
  }
  Tr.build(1, n, 1);
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) dfs(i, 0);
  Tr.Push(1);
  scanf("%d", &q);
  while (q--) {
    int L, R;
    scanf("%d%d", &L, &R);
    int l = 0, r = R - L;
    if (Tr.nxt[L] > R) {
      printf("%lld\n", 1ll * (R - L + 1) * (R - L + 2) / 2);
      continue;
    }
    while (l < r - 1) {
      int mid = (l + r) >> 1;
      if (Tr.nxt[L + mid] > R)
        r = mid;
      else
        l = mid;
    }
    l += L;
    cout << Tr.Query(L, l, 1) + 1ll * (R - l) * (R - l + 1) / 2 << endl;
  }
  return 0;
}
