#include <bits/stdc++.h>
using namespace std;
vector<long long> G[300005], cir[300005];
long long n, m, q, bel[300005], dep[300005], fa[300005], sz[100005],
    nxt[300005], cou[100005], sum[300005], cnt;
void get(long long x, long long y) {
  if (dep[x] < dep[y]) return;
  ++cnt;
  cir[cnt].push_back(y);
  bel[y] = cnt;
  while (x != y) cir[cnt].push_back(x), bel[x] = cnt, x = fa[x];
  sz[cnt] = cir[cnt].size();
}
void dfs(long long now, long long pre) {
  fa[now] = pre;
  dep[now] = dep[pre] + 1;
  for (unsigned int i = 0; i < G[now].size(); ++i) {
    long long to = G[now][i];
    if (to == pre) continue;
    if (dep[to])
      get(now, to);
    else
      dfs(to, now);
  }
}
void avoidWarning() {
  while (q-- > 0) {
    long long ll, rr;
    scanf("%lld %lld", &ll, &rr);
    long long l = ll, r = rr, ans = ll;
    while (l <= r) {
      long long mid = (l + r) >> 1;
      if (nxt[mid] < rr)
        l = mid + 1, ans = mid;
      else
        r = mid - 1;
    }
    if (nxt[ans] > rr) --ans;
    printf("%lld\n", (rr - ans) * (rr - ans + 1) / 2 + sum[ans] - sum[ll - 1] -
                         (ans - ll + 1) * (ans + ll - 2) / 2);
  }
}
int main() {
  scanf("%lld %lld", &n, &m);
  for (long long i = 1; i <= m; ++i) {
    long long u, v;
    scanf("%lld %lld", &u, &v);
    G[u].push_back(v);
    G[v].push_back(u);
  }
  for (long long i = 1; i <= n; ++i)
    if (!dep[i]) dfs(i, 0);
  long long l = 1, r = 0;
  while (l <= n) {
    while (r < n) {
      ++r;
      long long pos = bel[r];
      ++cou[pos];
      if (cou[pos] == sz[pos]) {
        --cou[pos];
        --r;
        break;
      }
    }
    nxt[l] = r;
    long long pos = bel[l];
    --cou[pos];
    ++l;
  }
  for (long long i = 1; i <= n; ++i) sum[i] = sum[i - 1] + nxt[i];
  scanf("%lld", &q);
  avoidWarning();
}
