Parabolic Teleports

No attempts yetTime limit2sMemory limit128 MB

Problem

Flatland is a plane with a Cartesian coordinate system OxyOxy. Its citizens are points that move at speed 11, so the minimum time to travel from a point VV to a point WW equals the length of the segment VWVW. Flatland schools teach this as the "shortest path theorem".

The theorem stopped holding once parabolic teleports were invented. A parabolic teleport is a contiguous arc of a parabola along which you can move at infinite speed: you can travel between any two points on the same teleport in zero time.

The points (x,y)(x, y) of a teleport satisfy y=Ax2+Bx+Cy = A x^2 + B x + C for XLxXRX_L \le x \le X_R, where AA, BB, CC, XLX_L, XRX_R are the teleport's parameters.

NN teleports have already been built. Given two points VV and WW, compute the minimum time needed to travel from VV to WW. You may walk in a straight line between any two points at speed 11, and you may step onto or off of any teleport at any of its points at no cost.

Input

The first line contains an integer NN (0N1000 \le N \le 100), the number of teleports. The second line contains two integers XVX_V and YVY_V (100XV100-100 \le X_V \le 100, 106YV106-10^6 \le Y_V \le 10^6), the coordinates of the source point VV. The third line contains two integers XWX_W and YWY_W (100XW100-100 \le X_W \le 100, 106YW106-10^6 \le Y_W \le 10^6), the coordinates of the destination point WW.

Each of the next NN lines contains five integers AiA_i, BiB_i, CiC_i, XLiX_{Li}, XRiX_{Ri} describing the ii-th teleport (100Ai,Bi,Ci100-100 \le A_i, B_i, C_i \le 100, Ai0A_i \ne 0, 100XLi<XRi100-100 \le X_{Li} < X_{Ri} \le 100).

Output

Print a single number: the minimum time to travel from VV to WW, rounded to exactly 44 digits after the decimal point.