#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
bool Max(T1& a, T2 b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T1, typename T2>
bool Min(T1& a, T2 b) {
  return a > b ? a = b, 1 : 0;
}
const int N = 300001;
vector<pair<int, int> > cycle;
vector<pair<int, int> > seg;
vector<long long> sum;
vector<int> g[N];
vector<int> stk;
bool vi[N];
int n;
void dfs(int i, int p) {
  stk.push_back(i);
  vi[i] = 1;
  for (auto& e : g[i])
    if (e != p) {
      if (!vi[e])
        dfs(e, i);
      else {
        if (stk.back() == i) {
          int mn = i, mx = i;
          while (1) {
            int cur = stk.back();
            stk.pop_back();
            Min(mn, cur);
            Max(mx, cur);
            if (cur == e) break;
          }
          cycle.push_back({mn, mx});
        }
      }
    }
  if (stk.back() == i) stk.pop_back();
}
long long calc(int l, int r, int end) {
  return (long long)(end - l + 1 + end - r + 1) * (r - l + 1) / 2;
}
void build() {
  cycle.push_back({0, 0});
  sort(cycle.begin(), cycle.end());
  set<int> end;
  for (auto& e : cycle) end.insert(e.second);
  end.insert(n + 1);
  int lastend = 0;
  for (auto& e : cycle) {
    end.erase(e.second);
    int curend = *end.begin() - 1;
    if (curend != lastend) {
      seg.push_back({e.first + 1, curend});
      lastend = curend;
    }
  }
  seg.push_back({n + 1, n + 1});
  sum.resize(seg.size());
  for (int i = 0; i < (int)(seg.size() - 1); ++i) {
    int l = seg[i].first;
    int r = seg[i + 1].first - 1;
    int end = seg[i].second;
    long long v = calc(l, r, end);
    sum[i] = v;
    if (i > 0) sum[i] += sum[i - 1];
  }
}
long long query(int l, int r) {
  int pos = upper_bound(seg.begin(), seg.end(), pair<int, int>{l, n}) - 1 -
            seg.begin();
  if (seg[pos].second >= r) {
    return calc(l, r, r);
  }
  int pos2 = lower_bound(seg.begin(), seg.end(), pair<int, int>{l, r},
                         [](pair<int, int> a, pair<int, int> b) {
                           return a.second < b.second;
                         }) -
             seg.begin();
  long long ans = sum[pos2 - 1];
  if (pos > 0) ans -= sum[pos - 1];
  ans -= calc(seg[pos].first, l - 1, seg[pos].second);
  ans += calc(seg[pos2].first, r, r);
  return ans;
}
void solve() {
  int m, u, v, q;
  cin >> n >> m;
  while (m--) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  stk.push_back(0);
  for (int i = 1; i <= (int)(n); ++i)
    if (!vi[i]) dfs(i, 0);
  build();
  cin >> q;
  while (q--) {
    cin >> u >> v;
    long long ans = query(u, v);
    cout << ans << '\n';
  }
}
void init() {}
int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.setf(ios::fixed);
  cout.precision(20);
  init();
  int TC = 1;
  for (int TI = 1; TI <= (int)(TC); ++TI) {
    solve();
  }
  return 0;
}
