#include <bits/stdc++.h>
using namespace std;
const int maxn = 303000;
int n, m, dfn[maxn], dfs_clock;
vector<int> G[maxn], pa;
vector<pair<int, int> > cyc;
void dfs(int u, int fa) {
  dfn[u] = ++dfs_clock;
  pa.push_back(u);
  for (auto v : G[u])
    if (v != fa) {
      if (dfn[v]) {
        if (dfn[v] < dfn[u]) {
          pair<int, int> cc = {v, v};
          auto cur = pa;
          while (cur.back() != v) {
            cc.first = min(cc.first, cur.back());
            cc.second = max(cc.second, cur.back());
            cur.pop_back();
          }
          cyc.push_back(cc);
        }
      } else
        dfs(v, u);
    }
  pa.pop_back();
}
int rb[maxn], cnt[maxn];
long long pre[maxn];
int bs(int lpos, int rpos) {
  int l = lpos, r = rpos;
  while (l < r) {
    int mid = (l + r) >> 1;
    if (rb[mid] < rpos)
      l = mid + 1;
    else
      r = mid;
  }
  return l;
}
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)
    if (!dfn[i]) dfs(i, -1);
  for (int i = 1; i <= n; ++i) rb[i] = n;
  for (auto [l, r] : cyc) rb[l] = min(rb[l], r - 1);
  for (int i = n - 1; i > 0; --i) {
    rb[i] = min(rb[i], rb[i + 1]);
    cnt[i] = rb[i] - i + 1;
  }
  for (int i = 1; i <= n; ++i) pre[i] = pre[i - 1] + cnt[i];
  int q;
  scanf("%d", &q);
  while (q--) {
    int l, r;
    scanf("%d%d", &l, &r);
    int o = bs(l, r);
    printf("%lld\n",
           pre[o - 1] - pre[l - 1] + 1LL * (r - o + 2) * (r - o + 1) / 2);
  }
  return 0;
}
