Dragon Ball Super
题号:NC15534
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 128 M,其他语言256 M
64bit IO Format: %lld

题目描述

Dragon Ball Super has finished. As a fan of Dragon Ball, Ctr couldn’t forget any plot of it, especially the fighting scene of Tournament of Power(力量大会). People who participate in the Tournament of Power will become the teammate with those who come from the same universe, even Son Goku and Frieza.
There are n people who may participate in the Tournament of Power, these people are numbered from 1 to n. Also there are m relations (ai,bi) which means person ai and person bi are come from the same universe.
Ctr defines the interest value of the Tournament of Power is the number of different universes people, participate in Tournament of Power, come from.
Now, Ctr has q queries to ask you, each of which contains two integers: l,r. For each query you are required to tell him the interest value when people ( l,l+1,...,r ) participate in the Tournament of Power.

输入描述:

The first line contains an integer number T, the number of test cases.
For each test case : 
The first line contains two integer numbers n,m(1 ≤ n,m ≤ 105), the number of test cases.
The following m lines, each contains two integers ai,bi(1 ≤ ai,bi ≤ n), which means aith person and bith person are come from the same universe.
The next line contains an integer number q(1 ≤ q ≤ 105), the number of query.
The following q lines, each contains two integers l,r(1 ≤ l ≤ r ≤ n).

输出描述:

For each query print the answer.
示例1

输入

复制
1
6 3
1 2
3 4
5 6
2
2 5
2 4

输出

复制
3
2