#P7661. [COCI 2014/2015 #5] TRAKTOR

[COCI 2014/2015 #5] TRAKTOR

Description

Given nn points on a plane, each point has coordinates given by positive integers Xi,YiX_i, Y_i. Find the minimum ansans such that among the first ansans points, there are at least kk points lying on the same row, or the same column, or the same diagonal-parallel slanted line.

Input Format

The first line contains two positive integers n,kn, k.

The next nn lines each contain two positive integers Xi,YiX_i, Y_i.

Output Format

Output one positive integer ansans. If there is no solution, output 1-1.

4 3
1 2
3 4
3 2
4 5
4
7 4
3 1
2 2
4 1
3 2
2 3
1 4
1 3
6
5 2
1 1
2 1
1 2
1 3
1 4
2

Hint

For 50%50\% of the testdata, 1Xi,Yi3001 \leq X_i, Y_i \leq 300.

For 100%100\% of the testdata, 2kn1062 \leq k \leq n \leq 10^6, 1Xi,Yi1051 \leq X_i, Y_i \leq 10^5.

Sample 1 Explanation:

.

Translated from COCI 2014/2015 CONTEST #5.

Translated by ChatGPT 5