Chef and His Garden

All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef is an advocate for Go Green Initiative. Today he had n trees planted in a row outside his his restaurant. Today, the height of ith tree is h_{i} feet. The trees grow at a rate of m_{i} feet per day.
Chef knows that trees will look beautiful if they form a zigzag sequence. The trees will be said to be in Zigzag sequence if the heights of tree first increases or decreases, then alternates between decreasing/increasing respectively. Formally, the trees will be said to in Zigzag sequence if one of the following two conditions holds.
 h_{1} < h_{2} > h_{3} < h_{4} and so on..
 h_{1} > h_{2} < h_{3} > h_{4} and so on..
Chef wants to know intervals of time when the heights of the trees will form a zigzag sequence.
Input
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
The first line of each test case contains a single integer n, denoting the number of trees.
The i^{th} of following N lines contains two space separated integers h_{i} and m_{i}, denoting the initial height and the growth speed for i^{th} tree.
Output
For each test case, output an integer Q  the amount of the periods of consecutive moments of time, when the trees for a zigzag sequence.
On the following Q lines, output the intervals of time when the trees' heights form a zigzag sequence. For each intervals, output its' smallest and the largest instants of time. If the range is infinite, output Inf as the right bound.
The test cases are designed in such a way that the total output won't exceed 2 MB.
Constraints
 1 ≤ T ≤ 10^{5}
 1 ≤ n ≤ 10
 Subtask 1 (23 points): 0 ≤ h_{i}, m_{i} ≤ 10
 Subtask 2 (77 points): 0 ≤ h_{i}, m_{i} ≤ 10^{9}
 1 ≤ sum of n over a test cases in a single test file ≤ 5 × 10^{5}
Example
Input: 3 3 0 1 2 2 0 3 2 2 1 1 2 3 1 1 2 2 3 3 Output: 1 0 1 2 0 0 2 Inf 0
Explanation
Example case 1. In the first case 0 2 0 is already a zigzag sequence, but on the 2nd second it will become 2 6 6 and will never turn back into zigzag
Author:  witalij_hq 
Tester:  xcwgf666 
Editorial  http://discuss.codechef.com/problems/CHAHG 
Tags  aug16, easy, witalij_hq 
Date Added:  23022015 
Time Limit:  2 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 