#K606. Closest Star Finder Problem

    ID: 31122 Type: Default 1000ms 256MiB

Closest Star Finder Problem

Closest Star Finder Problem

Given a reference point in a 2D Cartesian plane and a set of stars (each represented by its (x, y) coordinates), your task is to determine the closest star to the reference point using the Euclidean distance. The Euclidean distance between two points ( (x_1, y_1) ) and ( (x_2, y_2) ) is given by: ( d = \sqrt{(x_2 - x_1)^2 + (y_2 - y_1)^2} ). In the event of ties, choose the star that appears first in the input list.

inputFormat

The input is given via standard input (stdin). The first line contains two space-separated integers representing the x and y coordinates of the reference point. The second line contains an integer (N) indicating the number of stars. Each of the following (N) lines contains two space-separated integers representing the coordinates of a star.

outputFormat

Output to standard output (stdout) two space-separated integers representing the coordinates of the star closest to the reference point.## sample

0 0
1
1 2
1 2