2078: Under Attack

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:43 解决:19

题目描述

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?

输入

The input consists of multiple cases. 
The first line is the runway length LL 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 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.

样例输入 复制

10
1 5 2
6 9 2
-1 -1 -1

样例输出 复制

1 9