Klivvr Challenge
Problem-Solving Challenge

Nearest Klivvr Branch šŸ“Œ
Time limit per test: 1 Second
Memory limit per test: 128 Megabytes

Kero has just downloaded the Klivvr app and completed registration. Kero is now ready to pick up his Klivvr card šŸ’³. There is a numerous list of branches that Kero can visit to pick up his card. But Kero is a bit lazy, so he wants to minimize the distance he travels. He aims to visit the nearest cool šŸ˜Ž branch to his home. A branch is considered cool if the distance between the branch and Kero's home is an integer that's the result of multiplying an odd number by itself. For example, if a branch is 9 kilometers away from Kero's home, then it's cool because 9 is the result of multiplying 3, which is an odd number, by itself (3 * 3 = 9).

Kero lives in a 2D plane a.k.a Euclidean plane. You are given the coordinates of Kero's home and the coordinates of the branches. Kero asked you to help him find the nearest cool branch to his home. If such branch doesn't exist, print -1. If there are multiple answers print the one that appears first in the list of branches.

Input
Standard Input

The first line contains two space-separated integers x and y.

(-103 ≤ x, y ≤ 103) — The coordinates of Kero's home.

The second line contains an integer N.

(1 ≤ N ≤ 103) — The number of Klivvr branches.

Then followed by N lines where each line contains the description of the i-th branch.

(1 ≤ |Si| ≤ 50) — The name of the i-th branch, consists of lowercase and uppercase English letters only.
(-103 ≤ Xi, Yi ≤ 103) — The coordinates of the i-th branch.

Output
Standard Output

The output should consist of a single line containing the name of the nearest cool branch to Kero's home or -1 if no such branch exists.

Example

Input

2 2
4
Heliopolis -7 2
Zamalek 2 5
Maadi 2 -2
Zayed -13 -18

Output

Heliopolis

Explanation

Kero is located at (2, 2). We have 4 branches.

graph

Heliopolis is located at (-7, 2). The distance between Kero's home and Heliopolis is 9, which is cool.

Zamalek is located at (2, 5). The distance between Kero's home and Zamalek is 3.

Maadi is located at (2, -2). The distance between Kero's home and Maadi is 4.

Zayed is located at (-13, -18). The distance between Kero's home and Zayed is 25, which is cool as well.

We have 2 cool branches, Heliopolis and Zayed. Heliopolis is the nearest cool branch to Kero's home.

Made with by Kerollos Magdy
UI was originally developed by Amr Salama for the 2019 AFCON challenge

Submit Your Solution

The winners will be announced soon

Submit
Facing any issues?
Please let us know by opening an issue
GitHub