Lunar Landscape

Compute the total area covered by axis-aligned squares and 45-degree rotated squares, counting overlaps once.

Hard9GeometrySortingImplementationNo attempts yetTime limit2sMemory limit512 MB

Problem

A satellite is surveying a possible rover landing area on the moon. The landing area is a square grid placed in the standard coordinate system.

The satellite has taken nn photos, and each photo captures one square area of the surface. The camera is calibrated carefully, so every photo is aligned with the grid: all four vertices have integer coordinates. The orbit of the satellite changes, so there are two types of photos.

  • A photo of type A has sides parallel to the coordinate axes. It is given by the integer coordinates (x,y)(x, y) of the center of the square and the side length aa, which is always even.
  • A photo of type B has sides at 4545 degrees to the coordinate axes. It is given by the integer coordinates (x,y)(x, y) of the center of the square and the diagonal length dd, which is always even.

Find the total area of the surface captured in the photos. Area that several photos cover counts once.

Input

The first line contains the number of photos nn (1n2000001 \le n \le 200\,000).

Each of the next nn lines describes one photo in the form A x y a or B x y d, for a photo of type A or of type B. xx and yy are the integer coordinates of the center of the photo (1000x,y1000-1\,000 \le x, y \le 1\,000). aa is the side length and dd is the diagonal length, and both are even (2a,d10002 \le a, d \le 1\,000).

Output

Print the total area of the captured surface with exactly two digits after the decimal point. The output has to match the reference answer exactly, and rounding errors are not accepted.

Notes

The layout of the photos in example 1.

The layout of the photos in example 2.