PivotOJ

PASTELE

시간 제한: 5000ms메모리 제한: 160MB출처: COCI 2011-2012BOJ 2802

문제

Mirko recently got N crayons as a gift. The color of each crayon is a combination of three primary colors: red, green and blue. The color of the ith crayon is represented with three integers: Ri for the red, Gi for the green and Bi for the blue component.

The difference between the ith and the jth crayon is max(|Ri - Rj|, |Gi - Gj|, |Bi - Bj|). The colorfulness of a subsequence of crayons is equal to the largest difference between any two crayons in the subsequence.

Mirko needs a subsequence with K crayons with the smallest colorfulness for his drawing. The subsequence does not have to be consecutive. Find it!

입력

The first line of input contains integers N and K (2 ≤ K ≤ N ≤ 100 000).

The ith of the folowing N lines contains three integers Ri, Gi and Bi (0 ≤ Ri, Gi, Bi ≤ 255).

출력

The first line of output should contain the smallest colorfulness of a subsequence with K crayons.

The following K lines should contain the R, G and B values of the colors of the crayons in the subsequence, in any order. Any subsequence that yields the smallest colorfulness will be accepted.

예제

예제 1

입력
2 2
1 3 2
2 6 4
출력
3
1 3 2
2 6 4

예제 2

입력
3 2
3 3 4
1 6 4
1 1 2
출력
2
3 3 4
1 1 2

예제 3

입력
5 3
6 6 4
6 2 7
3 1 3
4 1 5
6 2 6
출력
2
6 2 7
4 1 5
6 2 6
코드를 제출하려면 로그인하세요.