Question
Friendly Interval Merge

Given closed intervals and a grace gap g, merge two blocks whenever they overlap, touch, or the gap between them is at most g.

Input

First line: KaTeX can only parse string typed expression.
Next KaTeX can only parse string typed expression lines: KaTeX can only parse string typed expression.

Output

Print the number of merged blocks and then the blocks in increasing order.

Example
Input:
5 2

1 3
6 8
9 10
20 22
23 23
Output:
3

1 3
6 10
20 23

Online