401730: GYM100519 B Bring Your Own Bombs

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Bring Your Own Bombstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

A sabotage platoon has completed its mission and planted some bombs on an enemy territory. Now they are about to report to their commanders how many enemy units will be destroyed. They have assigned this task to you.

The enemy territory is represented by a tile grid where the enemy platoons are located. Enemy units are standing in platoons that are represented by accurate rectangles, and they do not intersect each other. Each tile contains at most one enemy unit. Bombs have awesome firepower that can destroy all enemy units on the same tile line with the bomb: either horizontal or vertical, but not both. Unfortunately, all bombs are created manually by inexperienced engineers, and therefore, it is very hard to say how and if they explode or not. Only two values are known for certain for each bomb: p1, the probability that the bomb will explode horizontally, and p2, the probability that the bomb will explode vertically. It is implicitly known that with probability of 100% - p1 - p2 the bomb will not explode at all.

The sabotage platoon only plants the bombs outside the enemy platoons. Given the description of the enemy territory and planted bombs, you are to calculate the expected number of destroyed enemy units.

Input

The first line contains two integers N and M: the number of enemy platoons and bombs respectively (1 ≤ N, M ≤ 105).

The next N lines of input contain the descriptions of enemy platoons, one per line. Each platoon is described by four integers x1, y1, x2, y2: the coordinates of the tiles at the opposite corners of the rectangle (x1 ≤ x2, y1 ≤ y2).

Then the next M lines of input contain the description of bombs, one per line. Each bomb is described by integers x, y and numbers p1, p2: the coordinates of the tiles with bombs and the quality characteristics of the bombs given as an non-negative integer percentage respectively (p1 + p2 ≤ 100).

All coordinates do not exceed 109 by absolute value.

Output

Output must contain a single real number: the answer to the problem with absolute or relative error no more than 10 - 9.

ExamplesInput
1 1
-1 -1 1 1
0 3 33 33
Output
0.990000000000000
Input
1 2
1 1 5 5
0 2 100 0
2 0 0 100
Output
9.000000000000000
Input
2 2
0 3 2 5
3 0 5 2
1 1 30 60
4 4 50 40
Output
4.980000000000000

加入题单

算法标签: