#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream& operator<<(ostream& out, const pair<A, B>& a) {
  return out << "(" << a.first << ", " << a.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (int i = 0; i < v.size(); ++i) {
    if (v[i] != 1000000001)
      os << v[i];
    else
      os << "INF";
    if (i != v.size() - 1) os << ", ";
  }
  os << "]\n";
  return os;
}
const int N = 3e5 + 10;
vector<int> adj[N] = {}, adj2[N] = {};
vector<int> vis(N);
pair<bool, int> dfs(int u = 0, int p = -1) {
  vis[u] = 1;
  pair<bool, int> temp = make_pair(false, -1);
  for (auto v : adj[u]) {
    if (v - p) {
      if (vis[v] == 1) {
        temp = make_pair(true, v);
        adj2[v].push_back(u);
      } else if (!vis[v]) {
        pair<bool, int> p = dfs(v, u);
        if (p.first) {
          adj2[p.second].push_back(u);
          temp = p;
        }
      }
    }
  }
  vis[u] = 2;
  if (!temp.first || u == temp.second) temp = make_pair(false, -1);
  return temp;
}
long long int f(vector<long long int>& pref, int l, int r) {
  if (r < 0) return 0;
  if (l > 0)
    return pref[r] - pref[l - 1];
  else
    return pref[r];
}
int main() {
  {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  };
  int n, m;
  cin >> n >> m;
  while (m--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  vector<pair<int, int> > w;
  vector<int> next(N);
  vector<long long int> pref(N);
  for (int i = 0; i < n; i++) {
    if (!vis[i]) dfs(i);
  }
  for (int i = 0; i < n; i++) {
    vector<int> v = adj2[i];
    if (v.size() == 0) continue;
    int max1 = -1, min1 = 1000000001;
    for (int i = 0; i < v.size(); i++) {
      max1 = max(max1, v[i]);
      min1 = min(min1, v[i]);
    }
    w.push_back(make_pair(min1, max1));
  }
  sort(w.begin(), w.end());
  for (int i = 0; i < n; i++) next[i] = n;
  int right = n;
  for (int i = w.size() - 1; i >= 0; i--) {
    next[w[i].first] = w[i].second;
  }
  for (int i = n - 1; i >= 0; i--) {
    right = min(next[i], right);
    next[i] = right;
    pref[i] = right - i;
  }
  for (int i = 1; i < n; i++) pref[i] += pref[i - 1];
  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    int beg = a, end = b;
    long long int ans = a - 1;
    while (beg <= end) {
      int mid = (beg + end) >> 1;
      if (next[mid] <= b) {
        ans = mid;
        beg = mid + 1;
      } else
        end = mid - 1;
    }
    long long int count = f(pref, a, ans) + ((b - ans) * (b - ans + 1)) / 2;
    cout << count << endl;
  }
  return 0;
}
