You are given an undirected graph with n vertices. There are no edge-simple cycles with the even length in it. In other words, there are no cycles of even length that pass each edge at most once. Let's enumerate vertices from 1 to n. 

You have to answer q queries. Each query is described by a segment of vertices [l; r], and you have to count the number of its subsegments [x; y] (l ≤ x ≤ y ≤ r), such that if we delete all vertices except the segment of vertices [x; y] (including x and y) and edges between them, the resulting graph is bipartite.

Input

The first line contains two integers n and m (1 ≤ n ≤ 3·105, 1 ≤ m ≤ 3·105) — the number of vertices and the number of edges in the graph.

The next m lines describe edges in the graph. The i-th of these lines contains two integers ai and bi (1 ≤ ai, bi ≤ n; ai ≠ bi), denoting an edge between vertices ai and bi. It is guaranteed that this graph does not contain edge-simple cycles of even length.

The next line contains a single integer q (1 ≤ q ≤ 3·105) — the number of queries.

The next q lines contain queries. The i-th of these lines contains two integers li and ri (1 ≤ li ≤ ri ≤ n) — the query parameters.

Output

Print q numbers, each in new line: the i-th of them should be the number of subsegments [x; y] (li ≤ x ≤ y ≤ ri), such that the graph that only includes vertices from segment [x; y] and edges between them is bipartite.

Examples

Input

6 6
1 2
2 3
3 1
4 5
5 6
6 4
3
1 3
4 6
1 6


Output

5
5
14


Input

8 9
1 2
2 3
3 1
4 5
5 6
6 7
7 8
8 4
7 2
3
1 8
1 4
3 8


Output

27
8
19

Note

The first example is shown on the picture below:

<image>

For the first query, all subsegments of [1; 3], except this segment itself, are suitable.

For the first query, all subsegments of [4; 6], except this segment itself, are suitable.

For the third query, all subsegments of [1; 6] are suitable, except [1; 3], [1; 4], [1; 5], [1; 6], [2; 6], [3; 6], [4; 6].

The second example is shown on the picture below:

<image>
#include <bits/stdc++.h>
using namespace std;
char string_in_buffer[(int)260];
void fast_scan(int &first) { scanf("%d", &first); }
void fast_scan(long long &first) { scanf("%lld", &first); }
void fast_scan(unsigned long long &first) { scanf("%llu", &first); }
void fast_scan(double &first) { scanf("%lf", &first); }
void fast_scan(long double &first) { scanf("%Lf", &first); }
void fast_scan(char &first) {
  scanf("%c", &first);
  if (first == '\n') {
    fast_scan(first);
  }
}
void fast_scan(string &first) {
  scanf("%s", string_in_buffer);
  first = string(string_in_buffer);
}
template <class TFirst, class TSecond>
void fast_scan(pair<TFirst, TSecond> &p) {
  fast_scan(p.first);
  fast_scan(p.second);
}
template <class T>
void fast_scan(vector<T> &v) {
  for (auto &first : v) fast_scan(first);
}
void fast_print(const int &first) { printf("%d", first); }
void fast_print(const long long &first) { printf("%lld", first); }
void fast_print(const unsigned long long &first) { printf("%llu", first); }
void fast_print(const double &first) { printf("%.15lf", first); }
void fast_print(const long double &first) { printf("%.15Lf", first); }
void fast_print(const char &first) { printf("%c", first); };
void fast_print(const string &first) { printf("%s", first.c_str()); }
template <class TFirst, class TSecond>
void fast_print(const pair<TFirst, TSecond> &p) {
  fast_print(p.first);
  fast_print(' ');
  fast_print(p.second);
}
template <class T>
void fast_print(const vector<T> &v) {
  if (v.empty()) return;
  fast_print(v[0]);
  for (int i = 1; i < v.size(); i++) {
    fast_print(" ");
    fast_print(v[i]);
  }
}
template <class T>
void fast_print(const vector<vector<T>> &v) {
  if (v.empty()) return;
  fast_print(v[0]);
  for (int i = 1; i < v.size(); i++) {
    fast_print("\n");
    fast_print(v[i]);
  }
}
using namespace std;
namespace smart_io {
string print_start = "";
string sep = " ";
bool first_print = false;
void precall_print() {
  fast_print(print_start);
  print_start = "\n";
  first_print = true;
}
}  // namespace smart_io
template <class T>
ostream &operator,(ostream &os, const T &object) {
  if (!smart_io::first_print) {
    fast_print(smart_io::sep);
  } else {
    smart_io::first_print = false;
  }
  fast_print(object);
  return os;
}
template <class T>
istream &operator,(istream &is, T &object) {
  fast_scan(object);
  return is;
}
namespace typedefs {}
namespace numbers_operation {
template <class T>
T floor_mod(T a, T b) {
  if (a % b == 0) return 0;
  if (a >= 0 && b >= 0) return a % b;
  if (a <= 0 && b <= 0) return a % b;
  return abs(b) - (abs(a) % abs(b));
}
}  // namespace numbers_operation
using namespace numbers_operation;
using namespace typedefs;
const long long ONE = 512;
long long n, m;
vector<vector<long long>> g;
vector<bool> used;
vector<long long> tin;
vector<long long> up;
long long timer = 0;
void dfs(long long v) {
  tin[v] = timer++;
  used[v] = true;
  for (long long sub : g[v]) {
    if (used[sub]) continue;
    dfs(sub);
  }
}
set<pair<long long, long long>> bridges;
void find_bridges(long long v, long long _p) {
  up[v] = tin[v];
  used[v] = true;
  for (long long sub : g[v]) {
    if (used[sub]) {
      if (sub != _p) {
        up[v] = min(up[v], up[sub]);
      }
      continue;
    }
    find_bridges(sub, v);
    if (up[sub] > tin[v]) {
      bridges.emplace(v, sub);
      bridges.emplace(sub, v);
    }
    up[v] = min(up[v], up[sub]);
  }
}
vector<long long> at;
vector<vector<long long>> comps;
vector<long long> lt;
vector<long long> rt;
vector<long long> huihuihuihui;
vector<long long> sosatsosatsosatsosatsosat;
vector<long long> forleft;
void add_comp(long long v) {
  used[v] = true;
  comps.back().push_back(v);
  at[v] = ((long long)comps.size()) - 1;
  for (long long sub : g[v]) {
    if (used[sub]) continue;
    if (bridges.count(make_pair(v, sub))) continue;
    add_comp(sub);
  }
}
struct Query {
  long long l, r, id;
  Query() {}
  Query(long long _l, long long _r, long long _id) {
    l = _l;
    r = _r;
    id = _id;
  }
};
signed main(signed argc, char *argv[]) {
  {
    cin, n, m;
    g.resize(n);
    tin.resize(n);
    up.resize(n);
    at.resize(n);
    for (long long i = 0; i < m; i++) {
      long long a, b;
      cin, a, b;
      a--;
      b--;
      g[a].push_back(b);
      g[b].push_back(a);
    }
  }
  {
    used = vector<bool>(n, false);
    for (long long i = 0; i < n; i++) {
      if (!used[i]) {
        dfs(i);
      }
    }
  }
  {
    used = vector<bool>(n, false);
    for (long long i = 0; i < n; i++) {
      if (!used[i]) {
        find_bridges(i, -1);
      }
    }
  }
  {
    used = vector<bool>(n, false);
    for (long long i = 0; i < n; i++) {
      if (!used[i]) {
        comps.push_back(vector<long long>());
        add_comp(i);
      }
    }
  }
  {
    lt.resize(((long long)comps.size()), 1e9);
    rt.resize(((long long)comps.size()), -1e9);
    huihuihuihui.resize(((long long)comps.size()), 0);
    forleft.resize(n, -1);
    for (long long i = 0; i < ((long long)comps.size()); i++) {
      for (long long j : comps[i]) {
        lt[i] = min(lt[i], j);
        rt[i] = max(rt[i], j);
      }
    }
    for (long long i = 0; i < ((long long)comps.size()); i++) {
      if (((long long)comps[i].size()) > 1) {
        forleft[lt[i]] = rt[i];
      }
    }
  }
  {
    sosatsosatsosatsosatsosat.resize(n, 1e9);
    sosatsosatsosatsosatsosat[n - 1] = n - 1;
    for (long long i = n - 2; i > -1; i--) {
      if (forleft[i] != -1) {
        sosatsosatsosatsosatsosat[i] = forleft[i] - 1;
      }
      sosatsosatsosatsosatsosat[i] =
          min(sosatsosatsosatsosatsosat[i], sosatsosatsosatsosatsosat[i + 1]);
    }
  }
  {
    long long q;
    cin, q;
    vector<long long> pr(n);
    pr[0] = sosatsosatsosatsosatsosat[0];
    for (long long i = 1; i < n; i++) {
      pr[i] = pr[i - 1] + sosatsosatsosatsosatsosat[i];
    }
    auto get = [&pr](long long i) {
      if (i < 0) return 0LL;
      return pr[i];
    };
    for (long long i = 0; i < q; i++) {
      long long l, r;
      cin, l, r;
      l--;
      long long down = l - 1;
      long long up = r;
      while (up - down > 1) {
        long long mid = (down + up) / 2;
        if (sosatsosatsosatsosatsosat[mid] >= r) {
          up = mid;
        } else {
          down = mid;
        }
      }
      long long rez = get(up - 1) - get(l - 1);
      long long huihuihuihui = r - l;
      rez -= huihuihuihui * (long long)l +
             (huihuihuihui * (huihuihuihui - 1)) / 2 - huihuihuihui;
      rez += (r - up) * (r - 1);
      smart_io::precall_print();
      cout, rez;
    }
  }
}
