#include <bits/stdc++.h>
using namespace std;
const int black = 0, white = 1, grey = 2;
vector<int> find_cycles(const vector<vector<int>>& adj_list);
int main() {
  std::ios::sync_with_stdio(false);
  int nodes, edges;
  cin >> nodes >> edges;
  vector<vector<int>> adj_list(nodes);
  for (int i = 0; i < edges; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    adj_list[a].push_back(b);
    adj_list[b].push_back(a);
  }
  vector<int> first_bad = find_cycles(adj_list);
  vector<long long> good_sums(nodes + 1);
  for (int i = 0; i < nodes; i++)
    good_sums[i + 1] = good_sums[i] + first_bad[i] - i;
  int queries;
  cin >> queries;
  for (int i = 0; i < queries; i++) {
    int left, right;
    cin >> left >> right;
    left--;
    right--;
    auto end = first_bad.begin() + (right + 1);
    auto bound = upper_bound(first_bad.begin() + left, end, right);
    int good = bound - (first_bad.begin() + left);
    long long bad = right - left + 1 - good;
    long long first_part = good_sums[left + good] - good_sums[left];
    long long second_part = bad * (bad + 1) / 2;
    cout << first_part + second_part << '\n';
  }
}
pair<int, int> find_cycle(const vector<int>& stack, int stop) {
  int i = stack.size() - 1;
  int maximum = stop, minimum = stop;
  while (stack[i] != stop) {
    maximum = max(maximum, stack[i]);
    minimum = min(minimum, stack[i]);
    i--;
  }
  return make_pair(minimum, maximum);
}
void dfs(int node, const vector<vector<int>>& adj_list, vector<int>& color,
         vector<int>& first_bad, vector<int>& stack) {
  stack.push_back(node);
  color[node] = grey;
  for (int i = 0; i < adj_list[node].size(); i++) {
    int next = adj_list[node][i];
    if (color[next] == black)
      dfs(next, adj_list, color, first_bad, stack);
    else if (color[next] == grey && next != stack[stack.size() - 2]) {
      pair<int, int> cycle_edges = find_cycle(stack, next);
      first_bad[cycle_edges.first] = cycle_edges.second;
    }
  }
  color[node] = white;
  stack.pop_back();
}
vector<int> find_cycles(const vector<vector<int>>& adj_list) {
  vector<int> color(adj_list.size(), black),
      first_bad(adj_list.size(), adj_list.size());
  vector<int> stack;
  for (int i = 0; i < adj_list.size(); i++)
    if (color[i] == black) dfs(i, adj_list, color, first_bad, stack);
  for (int i = adj_list.size() - 2; i >= 0; i--)
    first_bad[i] = min(first_bad[i], first_bad[i + 1]);
  return first_bad;
}
