#include <bits/stdc++.h>
using namespace std;
void scanint(int &x) {
  register int c = getchar();
  bool flag = false;
  x = 0;
  for (; ((c < 48 && c != 45) || c > 57); c = getchar())
    ;
  if (c == 45) {
    flag = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (flag) x = x - (x << 1);
  return;
}
void scanll(long long &x) {
  register long long c;
  bool flag = false;
  x = 0;
  for (; ((c < 48 && c != 45) || c > 57); c = getchar())
    ;
  if (c == 45) {
    flag = true;
    c = getchar();
  }
  for (; c > 47 && c < 58; c = getchar()) {
    x = (x << 1) + (x << 3) + c - 48;
  }
  if (flag) x = x - (x << 1);
  return;
}
const int N = 300005;
vector<int> v[N];
bool visited[N];
int sufmin[N];
int R[N];
long long presum[N];
vector<pair<int, int> > oddCycles;
stack<int> rec;
stack<int> temp;
void backtrack(int val) {
  int mini = val, maxy = val;
  while (rec.top() != val) {
    temp.push(rec.top());
    mini = min(mini, rec.top());
    maxy = max(maxy, rec.top());
    rec.pop();
  }
  oddCycles.push_back(make_pair(mini, maxy));
  while (!temp.empty()) {
    rec.push(temp.top());
    temp.pop();
  }
  return;
}
map<pair<int, int>, int> M;
void dfs(int u, int parent) {
  rec.push(u);
  visited[u] = true;
  int pt;
  for (int i = 0; i < v[u].size(); i++) {
    pt = v[u][i];
    if (pt != parent && M[make_pair(u, pt)] == 0) {
      if (visited[pt]) {
        M[make_pair(pt, u)] = 1;
        backtrack(pt);
      } else
        dfs(pt, u);
    }
  }
  rec.pop();
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, a, b, q, l, r;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a >> b;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for (int i = 1; i <= n; i++)
    if (!visited[i]) dfs(i, i);
  for (int i = 1; i <= n; i++) sufmin[i] = n;
  for (int i = oddCycles.size() - 1; i >= 0; i--)
    sufmin[oddCycles[i].first] =
        min(sufmin[oddCycles[i].first], oddCycles[i].second - 1);
  for (int i = n - 1; i > 0; i--) sufmin[i] = min(sufmin[i + 1], sufmin[i]);
  presum[0] = 0;
  for (int i = 1; i <= n; i++)
    presum[i] = presum[i - 1] + (sufmin[i] - i + 1LL);
  for (int i = 1; i <= n; i++) R[sufmin[i]] = i;
  for (int i = 1; i <= n; i++) R[i] = max(R[i], R[i - 1]);
  int r1;
  long long len;
  cin >> q;
  while (q--) {
    cin >> l >> r;
    r1 = max(R[r], l - 1);
    len = r - r1;
    cout << presum[r1] - presum[l - 1] + (len * (len + 1LL)) / 2LL << "\n";
  }
  return 0;
}
