Segments

Given N vertical segments at increasing x, pick A on segment 1 and B on segment N uniformly; find the probability that chord AB crosses every segment.

Medium7GeometryProbabilityMathNo attempts yetTime limit0.5sMemory limit256 MB

Problem

Little Luka likes to doodle in his notebook during chemistry class. You can think of a page of his notebook as the coordinate plane.

This time Luka drew NN segments parallel to the yy-axis, all at different xx coordinates. The segments are numbered from 11 to NN in increasing order of their xx coordinate.

Now Luka wants to draw one more segment ABAB that crosses all NN segments, so that his doodle looks like a fish bone.

Luka does not know how to find such a segment, so he decided to pick one at random. He places point AA somewhere on segment 11 and point BB somewhere on segment NN.

During the random choice, every point of a segment is equally likely to be picked. More precisely, Luka picks AA and BB independently, each one uniformly from its own segment.

Write a program that computes the probability that segment ABAB touches every one of the NN drawn segments.

Input

The first line contains the number of segments NN (2N10002 \le N \le 1000).

Each of the next NN lines contains three positive integers xx, y1y_1, and y2y_2 (1x10001 \le x \le 1000, 1y1<y210001 \le y_1 < y_2 \le 1000), the coordinates of a segment parallel to the yy-axis. The segment joins the points (x,y1)(x, y_1) and (x,y2)(x, y_2). The segments are given in order of their numbers, that is, in increasing order of xx.

Output

Print on a single line the probability that segment ABAB touches every one of the NN drawn segments. The probability is a real number between 00 and 11 inclusive. Round it to 1010 digits after the decimal point and print exactly 1010 digits after the decimal point.