#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
int i, j, k, m, n, s, t, q;
const int N = 3e5 + 10;
vector<int> a[N];
int maxn[N][20], minu[N][20], fa[N][20];
int b[N][2], c[N], dep[N];
long long sum[N];
int get_min(int u, int v) {
  int p = dep[u] - dep[v] + 1;
  int ret = 1e9;
  for (int i = 0; i <= 19; i++)
    if (p & (1 << i)) {
      ret = min(ret, minu[u][i]);
      u = fa[u][i];
    }
  return ret;
}
int get_max(int u, int v) {
  int p = dep[u] - dep[v] + 1;
  int ret = 0;
  for (int i = 0; i <= 19; i++)
    if (p & (1 << i)) {
      ret = max(ret, maxn[u][i]);
      u = fa[u][i];
    }
  return ret;
}
void dfs(int u, int f) {
  maxn[u][0] = minu[u][0] = u;
  for (int i = 1; i <= 19; i++)
    fa[u][i] = fa[fa[u][i - 1]][i - 1],
    maxn[u][i] = max(maxn[u][i - 1], maxn[fa[u][i - 1]][i - 1]),
    minu[u][i] = min(minu[u][i - 1], minu[fa[u][i - 1]][i - 1]);
  for (int v : a[u]) {
    if (v == f) continue;
    if (dep[v]) {
      if (dep[u] < dep[v]) continue;
      ++t, b[t][0] = get_min(u, v), b[t][1] = get_max(u, v);
      continue;
    }
    dep[v] = dep[u] + 1;
    fa[v][0] = u;
    dfs(v, u);
  }
}
signed main() {
  memset(c, 1, sizeof(c));
  read(n), read(m);
  for (i = 1; i <= m; i++) {
    int x, y;
    read(x), read(y);
    a[x].push_back(y);
    a[y].push_back(x);
  }
  for (i = 1; i <= n; i++) {
    if (dep[i]) continue;
    dep[i] = 1;
    dfs(i, 0);
  }
  c[n + 1] = n + 1;
  for (i = 1; i <= t; i++) {
    if (b[i][0] == b[i][1]) continue;
    c[b[i][0]] = min(c[b[i][0]], b[i][1]);
  }
  for (i = n; i >= 1; i--) c[i] = min(c[i], c[i + 1]);
  for (i = 1; i <= n; i++) sum[i] = sum[i - 1] + c[i] - i;
  read(q);
  for (i = 1; i <= q; i++) {
    int l, r;
    read(l), read(r);
    int mid = upper_bound(c + 1, c + n + 1, r) - c - 1;
    mid = max(mid, l - 1);
    int len = r - mid;
    printf("%lld\n", sum[mid] - sum[l - 1] + 1ll * len * (1ll * len + 1) / 2);
  }
  return 0;
}
