Consider two infinite horizontal lines A and B, separated ℓ units apart. The line A has m points at the abscissae a1, …, am. The line B has n points at the abscissae b1, …, bn. Given p different indices i1, …, ip choosen from {1 … m}, and p different indices j1, …, jp choosen from {1 … n}, define dk as the Euclidean distance between aik and bjk, that is,
dk = | √ |
| . |
You are given ℓ, p, and the points in A and in B. Pick i1, …, ip and j1, …, jp in order to
Input
Input consists of several cases, each one with only integer numbers. Every case begins with four strictly positive numbers ℓ, p, m and n. Follow a1 ≤ a2 ≤ … ≤ am−1 ≤ am. Follow b1 ≤ b2 ≤ … ≤ bn−1 ≤ bn. Assume ℓ ≤ 106, p ≤ min(m, n), and that the absolute value of each abscissa is at most 106.
Additionally, assume that m and n are at most 105.
Output
For every case, print the result with four digits after the decimal point. If you use the long double type, the input cases have no precision issues.
Input
1 1 2 2 5 10 9 20 1 2 2 2 5 10 9 20 1000000 4 5 4 300000 300000 300000 300000 300000 -500000 -500000 -500000 -500000 3 2 7 4 0 2 4 6 8 10 12 1 4 7 10
Output
15.0333 15.0333 1280624.8475 11.4018