LearnPy Hub
← Arena
AdvancedRating 2000

The City Skyline

Buildings are rectangles standing on the ground: 'left right height'. Print the skyline as key points 'x height' where the outline's height changes, in order of x (one per line).

Input

n; then n lines 'l r h' with l < r.

Output

Lines 'x h'.

Sample 1

Input
5
2 9 10
3 7 15
5 12 12
15 20 10
19 24 8
Output
2 10
3 15
7 12
12 0
15 10
20 8
24 0

Sample 2

Input
2
0 2 3
2 5 3
Output
0 3
5 0
solution.py
Output appears here
The City Skyline · Python Arena problem · LearnPy Hub