#include <bits/stdc++.h>
using namespace std;
const int N = 300010, M = 600010;
int p = 1, tot, head[N], spot[M], nex[M];
int dfn[N], low[N], pre[N], f[M];
int fa[N];
int cnt[N], rm[N];
long long sum[N];
void add(int x, int y) {
  nex[++p] = head[x];
  head[x] = p;
  spot[p] = y;
  nex[++p] = head[y];
  head[y] = p;
  spot[p] = x;
}
void tarjan(int x) {
  dfn[x] = low[x] = ++tot;
  for (int tp = head[x]; tp; tp = nex[tp]) {
    int y = spot[tp];
    if (!dfn[y]) {
      pre[y] = tp;
      tarjan(y);
      low[x] = min(low[x], low[y]);
    } else if (pre[x] != (tp ^ 1))
      low[x] = min(low[x], dfn[y]);
  }
  if (pre[x] && low[x] == dfn[x]) f[pre[x]] = f[pre[x] ^ 1] = 1;
}
int get(int x) {
  if (fa[x] == x) return x;
  return fa[x] = get(fa[x]);
}
vector<int> c[N];
vector<int> mem[N];
int main() {
  int n, m, i, j, x, y, q;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    add(x, y);
  }
  for (i = 1; i <= n; i++)
    if (!dfn[i]) tarjan(i);
  for (i = 1; i <= n; i++) fa[i] = i;
  for (i = 1; i <= n; i++)
    for (int tp = head[i]; tp; tp = nex[tp])
      if (!f[tp]) {
        x = get(i), y = get(spot[tp]);
        if (x != y) fa[x] = y;
      }
  for (i = 1; i <= n; i++) c[get(i)].push_back(i);
  for (i = 1; i <= n; i++)
    if (c[i].size() > 1) {
      if (c[i].size() % 2 == 0)
        while (1)
          ;
      int minn = 1e9, maxn = 0;
      for (j = 0; j < c[i].size(); j++) {
        minn = min(minn, c[i][j]);
        maxn = max(maxn, c[i][j]);
      }
      mem[minn].push_back(maxn);
      cnt[maxn]++;
    }
  for (i = j = 1; i <= n; i++) {
    while (j < n && cnt[j + 1] == 0) j++;
    rm[i] = j;
    for (int k = 0; k < mem[i].size(); k++) cnt[mem[i][k]]--;
  }
  for (i = 1; i <= n; i++) sum[i] = sum[i - 1] + rm[i] - i + 1;
  for (cin >> q; q--;) {
    int l, r;
    scanf("%d%d", &l, &r);
    if (rm[l] > r) {
      long long ans;
      ans = ((long long)r - l + 2) * (r - l + 1) / 2;
      printf("%lld\n", ans);
      continue;
    }
    int from = l, to = r;
    while (from < to) {
      int mid = from + to + 1 >> 1;
      if (rm[mid] > r)
        to = mid - 1;
      else
        from = mid;
    }
    long long ans = sum[from] - sum[l - 1];
    ans += ((long long)1 + r - from) * (r - from) / 2;
    printf("%lld\n", ans);
  }
  return 0;
}
