#include <bits/stdc++.h>
using namespace std;
const int maxn = 300009;
vector<int> neigh[maxn];
int mn[maxn];
int depth[maxn];
int st[maxn];
int st_sz = 0;
void dfs(int v, int p) {
  st[st_sz++] = v;
  for (int u : neigh[v]) {
    if (u == p) continue;
    if (depth[u] == -1) {
      depth[u] = depth[v] + 1;
      dfs(u, v);
    } else if (depth[u] < depth[v]) {
      int a = 0, b = maxn;
      for (int i = depth[v]; i >= depth[u]; i--) {
        a = max(a, st[i]);
        b = min(b, st[i]);
      }
      mn[b] = min(mn[b], a - 1);
    }
  }
  st_sz--;
}
long long pref_sum[maxn];
int low[maxn];
int to[maxn];
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    neigh[u].push_back(v);
    neigh[v].push_back(u);
  }
  for (int i = 1; i <= n; i++) {
    mn[i] = n;
    depth[i] = -1;
  }
  for (int v = 1; v <= n; v++) {
    if (depth[v] == -1) {
      depth[v] = 0;
      dfs(v, 0);
    }
  }
  for (int v = n - 1; v >= 1; v--) {
    mn[v] = min(mn[v], mn[v + 1]);
  }
  for (int v = 1, j = 1; v <= n; v++) {
    pref_sum[v] = pref_sum[v - 1] + mn[v] - v + 1;
    while (j <= v && mn[j] <= v) j++;
    to[v] = j;
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int l, r;
    scanf("%d %d", &l, &r);
    long long ans = 0;
    int rr = max(to[r], l) - 1;
    ans =
        pref_sum[rr] - pref_sum[l - 1] + 1LL * (r - rr) * (r - rr + 1LL) / 2LL;
    cout << ans << endl;
  }
}
