Painters#4206

Painters

3 seconds
256 megabytes
Easy

A painting company has received an order to paint a long fence, which requires the work of multiple painters. The company manager assigned each painter to paint a section of the fence, from board number to board number (inclusive), using color . Each painter starts their task after the previous one has finished. However, due to some errors in task assignments, certain boards may have been painted more than once, while others might not have been painted at all. The company director has collected all the records of the painters' work and needs to determine which color would be the easiest to repaint the entire fence.

Your task is to calculate how many boards are painted in each color on the fence.

Input

The first line contains a single natural number (N \leq 10^5) — the number of painters involved. The following lines each contain three integers, X_i, Y_i, Z_i, separated by spaces. Here, 0 \leq X_i, Y_i \leq 10^9, 1 \leq Z_i \leq 10^5. These represent the starting board number, the ending board number, and the color used, respectively.

Output

Let be the number of distinct colors used on the boards. Output lines, each containing natural numbers separated by a space: the color number and the count of boards painted in that color. The output should be sorted in ascending order by the color number.

Examples

Example 1

Loading
Loading