#include <bits/stdc++.h>
using namespace std;
const int maxn = 300009;
int first[maxn], mn[maxn], pre[maxn], vis[maxn];
struct edg {
  int next, to;
} e[maxn << 1];
long long sum[maxn], sgm[maxn];
int n, m, q, e_sum;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
void add_edg(int x, int y) {
  e_sum++;
  e[e_sum].next = first[x];
  first[x] = e_sum;
  e[e_sum].to = y;
}
void dfs(int x, int from) {
  pre[x] = from;
  vis[x] = 1;
  for (int i = first[x]; i; i = e[i].next) {
    int w = e[i].to;
    if (w == from) continue;
    if (!vis[w])
      dfs(w, x);
    else if (vis[w] == 1) {
      int L = w, R = w;
      for (int t = x; t != w; t = pre[t]) {
        L = min(L, t);
        R = max(R, t);
      }
      mn[L] = min(mn[L], R - 1);
    }
  }
  vis[x] = 2;
}
int find(int L, int R) {
  int l = L, r = R, res = L - 1;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (mn[mid] <= R)
      res = mid, l = mid + 1;
    else
      r = mid - 1;
  }
  return res;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= m; i++) {
    int x = read(), y = read();
    add_edg(x, y);
    add_edg(y, x);
  }
  for (int i = 1; i <= n; i++) mn[i] = n;
  for (int i = 1; i <= n; i++)
    if (!vis[i]) dfs(i, 0);
  for (int i = n - 1; i >= 1; i--) mn[i] = min(mn[i], mn[i + 1]);
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + mn[i];
  for (int i = 1; i <= n; i++) sgm[i] = sgm[i - 1] + i - 1;
  q = read();
  while (q--) {
    int l = read(), r = read(), pos = find(l, r);
    printf("%I64d\n",
           sum[pos] - sum[l - 1] + 1ll * (r - pos) * r - (sgm[r] - sgm[l - 1]));
  }
  return 0;
}
