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>
import java.io.*;
import java.util.*;

public class C {

	int[] head;
	int[] to;
	int[] next;

	int[] vis;
	int[] path;
	int sz = 0;

	List<Integer> bad = new ArrayList<>();

	void dfs(int v, int p) {
		vis[v] = 1;
		path[sz++] = v;

		for (int e = head[v]; e >= 0; e = next[e]) {
			int u = to[e];
			if (u == p) {
				continue;
			}
			if (vis[u] == 1) {
				int min = u, max = u;
				for (int i = sz - 1; path[i] != u; i--) {
					min = Math.min(min, path[i]);
					max = Math.max(max, path[i]);
				}
				bad.add(min);
				bad.add(max);
			} else if (vis[u] == 0) {
				dfs(u, v);
			}
		}
		sz--;
		vis[v] = 2;
	}

	void submit() {
		int n = nextInt();
		int m = nextInt();

		head = new int[n];
		Arrays.fill(head, -1);
		to = new int[2 * m];
		next = new int[2 * m];

		for (int i = 0; i < m; i++) {
			int v = nextInt() - 1;
			int u = nextInt() - 1;

			to[2 * i] = u;
			next[2 * i] = head[v];
			head[v] = 2 * i;

			to[2 * i + 1] = v;
			next[2 * i + 1] = head[u];
			head[u] = 2 * i + 1;
		}

		vis = new int[n];
		path = new int[n];
		for (int i = 0; i < n; i++) {
			if (vis[i] == 0) {
				dfs(i, -1);
			}
		}

		int[] markFrom = new int[n + 1];
		Arrays.fill(markFrom, Integer.MAX_VALUE);
		for (int i = 0; i < bad.size(); i += 2) {
			int from = bad.get(i);
			int to = bad.get(i + 1);
			markFrom[from] = Math.min(markFrom[from], to);
		}

		for (int i = n - 1; i >= 0; i--) {
			markFrom[i] = Math.min(markFrom[i], markFrom[i + 1]);
		}

		int q = nextInt();

		Query[] qs = new Query[2 * q];

		for (int i = 0; i < q; i++) {
			int x = nextInt() - 1;
			int y = nextInt();
			qs[2 * i] = new Query(x, x, y, -1, i);
			qs[2 * i + 1] = new Query(y, x, y, 1, i);
		}

		Arrays.sort(qs);

		Node root = new Node(0, n);

		long[] outp = new long[q];

		int j = 0;
		for (int i = 0; i <= n; i++) {
			while (j < qs.length && qs[j].l == i) {
				long val = root.get(qs[j].lowR, qs[j].highR);
//				System.err.println(qs[j].lowR + " " + qs[j].highR + " " + val);
				outp[qs[j].qryId] += qs[j].sign * val;
				j++;
			}

			int ql = i;
			int qr = Math.min(markFrom[i], n);

//			System.err.println(ql + " " + qr);

			if (ql < qr) {
				root.add(ql, qr);
			}

		}

		for (long x : outp) {
			out.println(x);
		}

	}

	static class Query implements Comparable<Query> {
		int l;
		int lowR, highR;
		int sign;
		int qryId;

		public Query(int l, int lowR, int highR, int sign, int qryId) {
			this.l = l;
			this.lowR = lowR;
			this.highR = highR;
			this.sign = sign;
			this.qryId = qryId;
		}

		@Override
		public int compareTo(Query o) {
			return Integer.compare(l, o.l);
		}
	}

	static class Node {
		int l, r;
		Node left, right;

		long sum;
		int add;

		public Node(int l, int r) {
			this.l = l;
			this.r = r;
			if (r - l > 1) {
				int m = (l + r) >> 1;
				left = new Node(l, m);
				right = new Node(m, r);
			}
		}

		long getSum() {
			return sum + (long) add * (r - l);
		}

		void add(int ql, int qr) {
			if (l >= qr || ql >= r) {
				return;
			}
			if (ql <= l && r <= qr) {
				add += 1;
				return;
			}
			left.add += add;
			right.add += add;
			add = 0;

			left.add(ql, qr);
			right.add(ql, qr);
			sum = left.getSum() + right.getSum();
		}

		long get(int ql, int qr) {
			if (l >= qr || ql >= r) {
				return 0;
			}
			if (ql <= l && r <= qr) {
				return getSum();
			}
			left.add += add;
			right.add += add;
			add = 0;

			long ret = left.get(ql, qr) + right.get(ql, qr);
			sum = left.getSum() + right.getSum();
			return ret;
		}
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	C() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		// stress();
		// test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new C();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}
