#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const int mod = 998244353;
const int maxn = 2e6 + 4;
const int N = 5e3 + 5;
const double eps = 1e-6;
const double pi = acos(-1);
long long qpow(long long x, long long y) {
  long long ans = 1;
  x %= mod;
  while (y) {
    if (y & 1) ans = ans * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
int n, m, dfn[maxn], low[maxn], vis[maxn], tot;
int stk[maxn], top;
long long f[maxn], s[maxn];
vector<int> G[maxn];
void tar(int u, int fa) {
  dfn[u] = low[u] = ++tot;
  vis[u] = 1;
  stk[++top] = u;
  for (int v : G[u]) {
    if (v == fa) continue;
    if (!dfn[v]) {
      tar(v, u);
      low[u] = min(low[u], low[v]);
    } else {
      if (vis[v]) low[u] = min(low[u], dfn[v]);
    }
  }
  if (dfn[u] == low[u]) {
    vis[u] = 0;
    int mx = u, mi = u;
    ;
    while (stk[top] != u) {
      mx = max(mx, stk[top]);
      mi = min(mi, stk[top]);
      vis[stk[top--]] = 0;
    }
    top--;
    if (mx != mi) f[mi] = mx - 1;
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) f[i] = n;
  for (int i = 1; i <= n; i++) {
    if (!dfn[i]) {
      tar(i, -1);
    }
  }
  for (int i = n - 1; i >= 1; i--) f[i] = min(f[i + 1], f[i]);
  for (int i = 1; i <= n; i++) s[i] = f[i] - i + 1;
  for (int i = 1; i <= n; i++) s[i] += s[i - 1];
  int q;
  scanf("%d", &q);
  while (q--) {
    int x, y;
    scanf("%d%d", &x, &y);
    int l = x, r = y, ans = x;
    while (l <= r) {
      int mid = l + r >> 1;
      if (f[mid] >= y)
        r = mid - 1, ans = mid;
      else
        l = mid + 1;
    }
    printf("%lld\n",
           s[ans - 1] - s[x - 1] + 1ll * (y - ans + 1) * (y - ans + 2) / 2);
  }
}
