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 inf = 1e9;
const long long Inf = 1e18;
const int N = 3e5 + 10;
const int mod = 0;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
template <typename T>
bool chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
};
template <typename T>
bool chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
};
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
void inc(int &a, int b) { a = (a + b >= mod ? a + b - mod : a + b); }
void dec(int &a, int b) { a = (a - b < 0 ? a - b + mod : a - b); }
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + "," + to_string(p.second) + ")";
}
template <typename T>
string to_string(T v) {
  int fst = 1;
  string ret = "{";
  for (auto x : v) {
    if (!fst) ret += ",";
    fst = 0, ret += to_string(x);
  }
  ret += "}";
  return ret;
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  dbg_out(T...);
}
int to[N << 1], nxt[N << 1], h[N], tot = 1;
void adde(int u, int v) {
  to[++tot] = v, nxt[tot] = h[u], h[u] = tot;
  to[++tot] = u, nxt[tot] = h[v], h[v] = tot;
}
int n, m, q, L[N], dfn[N], low[N], tim = 0, st[N], tp = 0;
long long sum[N];
void dfs(int u, int fae) {
  dfn[u] = low[u] = ++tim;
  st[++tp] = u;
  for (int i = h[u]; i; i = nxt[i]) {
    if (i == (fae ^ 1)) continue;
    int v = to[i];
    if (!dfn[v])
      dfs(v, i), chkmin(low[u], low[v]);
    else
      chkmin(low[u], dfn[v]);
  }
  if (low[u] == dfn[u]) {
    int v, mn = inf, mx = -inf;
    do {
      v = st[tp--], chkmin(mn, v), chkmax(mx, v);
    } while (u != v);
    if (mx != mn) chkmax(L[mx], mn);
  }
}
int main() {
  n = gi(), m = gi();
  for (int i = 1; i <= m; i++) adde(gi(), gi());
  for (int i = 1; i <= n; i++)
    if (!dfn[i]) dfs(i, 0);
  for (int i = 1; i <= n; i++) chkmax(L[i], L[i - 1]);
  for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + L[i];
  q = gi();
  while (q--) {
    int ql = gi(), qr = gi();
    int l = ql, r = qr, ret = ql - 1;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (L[mid] < ql)
        ret = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    cout << 1ll * (ql + ret) * (ret - ql + 1) / 2 -
                1ll * (ret - ql + 1) * (ql - 1) +
                1ll * (ret + 1 + qr) * (qr - ret) / 2 - (sum[qr] - sum[ret])
         << '\n';
  }
  return 0;
}
