Three in line

Consider an n×nn \times n integer grid with exactly 2n2n points marked on it. Can you find three points in the same line?

Input

Input consists of several cases, each with nn, followed by 2n2n pairs (x,y)(x, y). Assume 3n1053 \le n \le 10^5, that xx and yy are integer numbers between 1 and nn, and that there are no repeated points.

Output

Print a line for every case. If there are no three (or more) points in any line, print “NO”. Otherwise, print “YES” followed by the three points that you found, in any order. If there is more than one solution, you can print any one. Follow strictly the format of the sample output.

Observation

The “large” private test cases were generated at random, by picking both xx and yy uniformly and independently, and descarting repeated points until having 2n2n in total.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T12:09:34.654Z

© Jutge.org, 2006–2026.
https://jutge.org