Chain
Consider an isothetic rectangle (where "isothetic" means "with sides parallel to coordinate axes"), left bottom corner has coordinates (0, 0), right top one — (x_max, y_max). There are N points P_1 (x_1, y_1), P_2 (x_2, y_2), …, P_N (x_N, y_N) inside the rectangle (0 < x_i < x_max, 0 < y_i < y_max). Consider polygonal chains SP_i1P_i2ΚP_ikF satisfying the following constraints:
All internal vertices P_ij are some of the given points; quantity of selected points can be any 0 ≤ k ≤ N;
Start vertex S (x_S, y_S) is located on the left side of the rectangle or outside it to the left (x_S ≤ 0, 0 ≤ y_S ≤y_max);
End vertex F(x_F, y_F) is located on the right side of the rectangle or outside it to the right (x_F ≥ x_max, 0 ≤ y_F≤ y_max).
Let’s call such chain constant-length if and only if Euclidean lengths of all segments are equal (|SP_i1| = |P_i1P_i2| = Κ = |P_ikF|). It’s easy to see that there is at least one constant-length polygonal chain for any rectangle and any set of given points: this is segment SF with coordinates S(0, 0), F(x_max, 0) which satisfies all the constraints.
Your task is to write a program to find a constant-length chain with minimal length of segment. It is easy to see that square (second degree) of the minimal length is always integer, so program should output square of the length, as integer number.
Input
The first line of input data contains three space-separated integers x_max y_max N — coordinates of the right-top corner and number of given points. Each of the following N lines contains two space-separated integers x_i y_i — coordinates of given point.
Constraints: 1 ≤ N ≤ 1000; 5 ≤ x_max, y_max ≤ 32000; for all 1 ≤ i ≤ N, 0 < x_i < x_max, 0 < y_i < y_max.
Output
Your program should write exactly one integer: square of the minimal possible segment length among constant-length polygonal chains.
Note: We may build some constant-length chains with length (for example: (–2, 6), (2, 8), (6, 6), (6+, 6)), but cannot build any constant-length chain for smaller lengths.