Limits 500ms, 512 MB

Suppose, there is an array of NN integers. Each index of the array is either red or green. The first index is red, then the following is green, then the very next one is again red, then green again and the pattern will be like this.

You are given m queries and each query contains pp, qq integers. Your task is to find out the number of red and green lie between the range pp and qq (inclusive).

Input

The first line of the input contains an integer TT (T50T ≤ 50) indicates the testcase. Following TT lines there will be two integers nn (1n1051 ≤ n ≤ 10^5), mm (1m2×1031 ≤ m ≤ 2 \times 10^3) indicates the size of array and the number of query respectively. The index will be 1, 2, ..., n. Then mm lines follows two integers pp, qq (1pq1051 ≤ p ≤ q ≤ 10^5) respectively.

Output

For each query print two integers rr and gg, the total number of red and green in the range. There is a space between rr and gg and don't forget to print new line after each query.

Sample

InputOutput
2
5 2
1 3
1 5
10  4
5 5
2 9
4 8
1 10
2 1
3 2
1 0
4 4
2 3
5 5

Submit

Login to submit.

Statistics

86% Solution Ratio
BruteforcekidEarliest, Jul '17
subhashis_cseFastest, 0.0s
SowmenLightest, 393 kB
Nerd_NafisShortest, 239B
Toph uses cookies. By continuing you agree to our Cookie Policy.