401680: GYM100513 E Election of a Mayor
Description
The Berland capital is preparing for mayoral election. There are two candidates for the position: the current mayor and his rival. The rival is a serious competitor, and it's not easy for current mayor to win the election.
The candidate will be declared the winner if he wins at more than a half of all polling stations. The results of the polling stations are supplied independently. The station winner is the candidate who gets more than a half of the votes of this station. No candidate is declared a winner of a polling station if both candidates have got the same number of votes at this station. Similarly, no candidate is declared a winner of the election if both candidates won at the same number of polling stations.
All eligible voters are going to take part in the election and have already decided whom to give their vote to. The campaign headquarters of the current mayor has collected data from all n stations of the city, and now for every station it is known how many people will vote for the current mayor and how many people will vote for his opponent.
The results have been disappointing for the current mayor, but his staff came up with a way to win the election. It was suggested to merge some pairs of polling stations in such a way that the current mayor will become the election winner. However, (for the sake of credibility), the proposed plan must comply with two conditions. Firstly, it is possible to merge only the pairs of stations with adjacent numbers (i.e., station j may be merged with either station j - 1, or with station j + 1). The resulting station cannot be merged again. Secondly, the number of such mergers for obvious reasons must be as few as possible.
Your task is to help the current mayor's campaign headquarters and produce such plan.
InputThe first line contains single integer n (2 ≤ n ≤ 2·105) — the number of the polling stations.
Each of the following n lines contains two integers mj and rj (0 ≤ mj, rj ≤ 105) — the number of voters at station j who plan to vote for the current mayor and his rival correspondingly.
OutputIf current mayor cannot win the election at any condition, print a single number - 1 to the first line.
Otherwise, to the first line print an integer u — the minimum number of polling station mergers the current mayor needs to perform in order to win. To each of the next u lines print a pair of integers — the numbers of the merged stations. The pairs as well as the numbers within each pair can be printed in any order. If there are multiple solutions, print any of them.
ExamplesInput7Output
15 8
8 10
14 14
12 13
13 12
21 10
20 30
2Input
1 2
6 7
2Output
1 5
5 1
-1Input
2Output
10 9
15 7
0