Jordan

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Michael likes to spend time with numbers... wait a minute, the statement should have a story about a mathematician!

Camille likes to spend time with numbers. This morning, he drew on a whiteboard an infinite number line and marked on it a finite set of distinct points with real coordinates. Also, for each of these points he chose some real non-negative value, named it weight of the point, and started to have fun. NN times Camille selected a segment \[l_i;r_i]\[l\_i; r\_i] on the number line and counted the sum of weights of all points lying inside this segment. In case you forget, point xx lies inside the segment \[l;r]\[l; r] if lxrl \leq x \leq r. He wrote all these calculations down to his notebook and left the room for a lunch.

Henri likes to tease Camille, and that was not an opportunity he could miss. While Camille was enjoying frog legs and young Bordeaux, Henri took a sponge and cleared the board completely. When the prank revealed, Camille's disappointment was out of description!

You accidentally witnessed this crime and now feel a little ashamed for not preventing it. Moreover, you still remember nice days spent together with Bernhard and Camille, when you were freshmen, so you decided to help him. Given his records, calculate minimum and maximum possible sum of weights of all the points. Assume that every marked point belongs to at least one segment selected by Camille.

입력

The first line of the input contains a single integer NN --- the number of records in Camille's notebook (1N10001 \le N \le 1000).

Next NN lines describe the calculations he performed. Each of them contains three integers. First two of them are l_il\_i and r_ir\_i --- borders of the segment, the last one is the sum of weights of all points lying inside this segment s_is\_i (109l_ir_i109-10^9 \le l\_i \le r\_i \le 10^9, 0s_i1090 \le s\_i \le 10^9).

출력

Print the minimum and maximum possible total weight of all points drawn by Camille. If the data is inconsistent print two numbers 1-1 instead.

힌트

In the first example, one can obtain the total weight 11 by having just one point with coordinate x=2x = 2 and weight 1. Also, one can obtain the total weight 22 by having  two points with weights 1 and coordinates x=1.5x = 1.5 and x=2.5x = 2.5 respectively.

In the second example, the input data is obviously inconsistent.