12 12
5 1
5 11
1 11
8 11
8 9
5 12
6 9
7 11
9 3
9 10
4 12
10 2
78
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2 10
2 11
2 12
3 3
3 4
3 5
3 6
3 7
3 8
3 9
3 10
3 11
3 12
4 4
4 5
4 6
4 7
4 8
4 9
4 10
4 11
4 12
5 5
5 6
5 7
5 8
5 9
5 10
5 11
5 12
6 6
6 7
6 8
6 9
6 10
6 11
6 12
7 7
7 8
7 9
7 10
7 11
7 12
8 8
8 9
8 10
8 11
8 12
9 9
9 10
9 11
9 12
10 10
10 11
10 12
11 11
11 12
12 12

1
3
6
10
15
21
28
36
45
55
65
76
1
3
6
10
15
21
28
36
45
55
66
1
3
6
10
15
21
28
36
45
55
1
3
6
10
15
21
28
36
45
1
3
6
10
15
21
28
36
1
3
6
10
15
21
28
1
3
6
10
15
21
1
3
6
10
15
1
3
6
10
1
3
6
1
3
1

#include <bits/stdc++.h>
using namespace std;
template <typename T>
using maxHeap = priority_queue<T, vector<T>, less<T>>;
template <typename T>
using minHeap = priority_queue<T, vector<T>, greater<T>>;
template <typename Iter>
ostream& _out(ostream& s, Iter b, Iter e) {
  s << "[";
  for (auto it = b; it != e; it++) s << (it == b ? "" : " ") << *it;
  s << "]";
  return s;
}
template <typename A, typename B>
ostream& operator<<(ostream& s, const pair<A, B>& p) {
  return s << "(" << p.first << "," << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& c) {
  return _out(s, begin(c), end(c));
}
bool debug = 0;
template <typename T>
void DEBUG(const T& x) {
  if (debug) cerr << x;
}
template <typename T, typename... Args>
void DEBUG(const T& head, const Args&... tail) {
  if (debug) {
    cerr << head;
    DEBUG(tail...);
  }
}
const int N = 300000 + 5;
class BCC {
 private:
  int n, m, cnt, bcnt;
  vector<vector<pair<int, int>>> G;
  vector<int> low, dfn, ids, sz;
  stack<int> stk;
  void dfs(int w, int f) {
    dfn[w] = cnt++;
    low[w] = dfn[w];
    for (auto i : G[w]) {
      int u = i.first, t = i.second;
      if (u == f) continue;
      if (dfn[u] == -1) {
        stk.push(t);
        dfs(u, w);
        if (low[u] >= dfn[w]) {
          while (stk.top() != t) {
            assert(!stk.empty());
            ids[stk.top()] = bcnt;
            sz[bcnt]++;
            stk.pop();
          }
          ids[stk.top()] = bcnt;
          sz[bcnt]++;
          stk.pop();
          bcnt++;
        }
        low[w] = min(low[w], low[u]);
      } else {
        if (dfn[u] < dfn[w]) stk.push(t);
        low[w] = min(low[w], dfn[u]);
      }
    }
  }

 public:
  void init(int n_, int m_) {
    n = n_, m = m_, cnt = 0;
    G.resize(n);
    fill(begin(G), end(G), vector<pair<int, int>>());
    low.resize(n);
    dfn.resize(n);
    fill(begin(dfn), end(dfn), -1);
    ids.resize(m);
    sz.resize(m);
  }
  void add_edge(int u, int v) {
    assert(0 <= u and u < n);
    assert(0 <= v and v < n);
    G[u].push_back({v, cnt});
    G[v].push_back({u, cnt});
    cnt++;
  }
  void solve() {
    assert(cnt == m);
    cnt = 1, bcnt = 0;
    for (int i = 0; i < n; i++) {
      if (dfn[i] != -1) continue;
      while (!stk.empty()) stk.pop();
      dfs(i, i);
    }
  }
  int count() { return bcnt; }
  int get_id(int t) { return ids[t]; }
  int get_size(int x) { return sz[x]; }
} bcc;
pair<int, int> egs[N], line[N];
int r[N];
long long preR[N];
int main(int argc, char* argv[]) {
  if (argc > 1 and string(argv[1]) == "-D") debug = 1;
  if (!debug) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  }
  int n, m;
  cin >> n >> m;
  bcc.init(n, m);
  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    bcc.add_edge(u - 1, v - 1);
    egs[i] = {u, v};
  }
  bcc.solve();
  for (int i = 1; i <= bcc.count(); i++) line[i] = {n, -1};
  for (int i = 0; i < m; i++) {
    int id = bcc.get_id(i) + 1;
    DEBUG(egs[i], " : ", id, '\n');
    if (debug)
      cerr << __PRETTY_FUNCTION__ << ":" << 148 << " - "
           << "bcc.get_size(id - 1)"
           << "=" << bcc.get_size(id - 1) << '\n';
    if (bcc.get_size(id - 1) == 1) continue;
    line[id].first = min({egs[i].first, egs[i].second, line[id].first});
    line[id].second = max({egs[i].first, egs[i].second, line[id].second});
  }
  fill_n(r + 1, n, n + 1);
  for (int i = 1; i <= bcc.count(); i++) {
    if (bcc.get_size(i - 1) == 1) continue;
    r[line[i].first] = min(line[i].second, r[line[i].first]);
    DEBUG("r[", line[i].first, "]=", r[line[i].first], '\n');
  }
  int rr = n + 1;
  for (int i = n; i >= 1; i--) {
    rr = min(r[i], rr);
    r[i] = rr;
  }
  for (int i = 1; i <= n; i++) DEBUG(r[i], " \n"[i == n]);
  for (int i = 1; i <= n; i++) preR[i] = preR[i - 1] + r[i];
  auto sumr = [](int ql, int qr) { return preR[qr] - preR[ql]; };
  int q;
  cin >> q;
  while (q--) {
    long long ql, qr;
    cin >> ql >> qr;
    ql--;
    long long ans = sumr(ql, qr) - (ql + qr + 1) * (qr - ql) / 2;
    int idx = distance(r, upper_bound(r + ql + 1, r + n + 1, qr));
    if (idx <= qr) ans -= sumr(idx - 1, qr) - (qr + 1) * (qr - idx + 1);
    cout << ans << '\n';
  }
  return 0;
}
