# Under Attack

Doctor serves at a military air force base. One day, the enemy launch a sudden attack and the base is under heavy fire. The fighters in the airport must take off to intercept enemy bombers. However, the enemies know this clearly and they now focus on destroying the runway. The situation is becoming worse rapidly!

Every part of the runway has a damage level. On each bombing run, the damage level is increased by the bomb's damage . Fortunately, the enemy bombers has to stop bombing the runway when they run out of ammo. Then the ground crew have time to evaluate the situation of runway so that they can come to repair the runway ASAP after enemy attacks. The most heavily-damaged part on fighters' taking off and landing path should first be repaired. Assume that runway start from north and head to south , and fighters will take off or land only from north to south or vice versa.

Now that the task is clear, the ground crew need the cooridinates of two points: first that is the most damaged point from north to south, second is the most damaged point from south to north.The base's central mainframe is down under hacker attack. So Doctor could only use his poor little and shabby notebook to fulfill this task. Can you help him?

Input

The input consists of multiple cases.
The first line is the runway length L. L can be up to 15000.
Next lines will describe enemy bombing runs ,each line describes effect range start end of each bombing run and enemy bomb damage d.if start is -1, this case ends..
There can be up to 3000 bombing run, each time the damage is up to 100.
Notice that the bombing range is from north to south, and runway range is [0,len].
Output

Output the cooridinates of two points: first that is the most damaged point from north to south, second is the most damaged point from south to north.

Sample Input

10
1 5 2
6 9 2
-1 -1 -1
Sample Output

1 9

2017/08/25 03:59
• hacker
• lines
• each
• 点赞
• 收藏
• 回答
私信