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;
const int N = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-10;
const int M = 1e9 + 7;
int dcmp(double first) {
  if (fabs(first) < eps) return 0;
  return first < 0 ? -1 : 1;
}
struct Edge {
  int u, v;
};
const int maxn = 1e6 + 10;
int pre[maxn], iscut[maxn], bccno[maxn], dfs_clock, bcc_cnt;
vector<int> G[maxn], bcc[maxn];
stack<Edge> S;
int dfs(int u, int fa) {
  int lowu = pre[u] = ++dfs_clock;
  int child = 0;
  for (int i = 0; i < G[u].size(); i++) {
    int v = G[u][i];
    Edge e = (Edge){u, v};
    if (!pre[v]) {
      S.push(e);
      child++;
      int lowv = dfs(v, u);
      lowu = min(lowu, lowv);
      if (lowv >= pre[u]) {
        iscut[u] = true;
        bcc_cnt++;
        bcc[bcc_cnt].clear();
        for (;;) {
          Edge first = S.top();
          S.pop();
          if (bccno[first.u] != bcc_cnt) {
            bcc[bcc_cnt].push_back(first.u);
            bccno[first.u] = bcc_cnt;
          }
          if (bccno[first.v] != bcc_cnt) {
            bcc[bcc_cnt].push_back(first.v);
            bccno[first.v] = bcc_cnt;
          }
          if (first.u == u && first.v == v) break;
        }
      }
    } else if (pre[v] < pre[u] && v != fa) {
      S.push(e);
      lowu = min(lowu, pre[v]);
    }
  }
  if (fa < 0 && child == 1) iscut[u] = 0;
  return lowu;
}
void find_bcc(int n) {
  memset(pre, 0, sizeof(pre));
  memset(iscut, 0, sizeof(iscut));
  memset(bccno, 0, sizeof(bccno));
  dfs_clock = bcc_cnt = 0;
  for (int i = 0; i < n; i++)
    if (!pre[i]) dfs(i, -1);
}
int ss[N], nn;
void add(int k, int first) {
  while (k <= nn) {
    ss[k] += first;
    k += (k & -k);
  }
}
int query(int k) {
  int ans = 0;
  while (k) {
    ans += ss[k];
    k -= (k & -k);
  }
  return ans;
}
vector<pair<long long, long long> > a;
long long sum[N];
long long ct(long long l, long long r) {
  if (r < l) return 0;
  return (r - l + 1) * (r - l + 2) / 2;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    u--;
    v--;
    G[u].push_back(v);
    G[v].push_back(u);
  }
  find_bcc(n);
  for (int i = 1; bcc[i].size(); i++) {
    if (bcc[i].size() <= 2) continue;
    sort(bcc[i].begin(), bcc[i].end());
    a.push_back(make_pair(bcc[i].front(), bcc[i].back()));
  }
  sort(a.begin(), a.end());
  nn = n;
  for (pair<long long, long long> k : a) add(k.second, 1);
  int n1 = 0;
  for (int i = 0; i < a.size(); i++) {
    add(a[i].second, -1);
    if (!query(a[i].second)) a[n1++] = a[i];
  }
  a.resize(n1);
  if (a.size()) sum[1] = ct(0, a[0].second - 1) + (a[0].second - a[0].first);
  for (int i = 1; i < a.size(); i++) {
    sum[i + 1] = sum[i];
    if (a[i - 1].second <= a[i].first)
      sum[i + 1] += ct(a[i].first, a[i].second) - 1 +
                    (long long)(a[i].second - a[i].first) *
                        (a[i].first - a[i - 1].first - 1);
    else
      sum[i + 1] += ct(a[i - 1].second, a[i].second) - 1 +
                    (long long)(a[i].second - a[i - 1].second - 1) *
                        (a[i - 1].second - a[i - 1].first - 1) +
                    (a[i - 1].second - a[i].first - 1);
  }
  int Q, cnt = 0;
  scanf("%d", &Q);
  while (Q--) {
    cnt++;
    long long first, second;
    scanf("%lld %lld", &first, &second);
    first--;
    second--;
    pair<long long, long long> tmp = make_pair(first, first);
    long long l = lower_bound(a.begin(), a.end(), tmp) - a.begin();
    tmp = make_pair(second, second);
    long long r = lower_bound(a.begin(), a.end(), tmp) - a.begin() - 1;
    while (r >= 0 && a[r].second > second) r--;
    if (r < l || l > a.size()) {
      printf("%lld\n", ct(first, second));
      continue;
    }
    long long ans =
        sum[r + 1] - sum[l + 1] + ct(first, a[l].second - 1) +
        (a[l].second - a[l].first) + ct(a[r].second + 1, second) +
        (long long)(a[r].second - a[r].first) * (second - a[r].second);
    printf("%lld\n", ans);
  }
  return 0;
}
