#D6606. Sheets

    ID: 5492 Type: Default 5000ms 134MiB

Sheets

Sheets

There are several rectangular sheets placed on a flat surface. Create a program to find the area and perimeter of the part covered by these sheets.

However, when the plane is regarded as the coordinate plane, the arrangement of the sheets shall satisfy the following conditions (1) and (2).

(1) The x and y coordinates of the four vertices of the rectangle on each sheet are all integers from 0 to 10000, and each side of the rectangle is parallel to the x-axis or y-axis.

(2) The number of sheets is at most 10,000 or less.

The number n of rectangles and the integer r indicating the type of problem are separated by a space in the first line of the input data. In each line after the second line, the coordinates of the lower left vertex of each sheet (x1, y1) and The coordinates of the upper right vertex coordinates (x2, y2) are written in the order of x1, y1, x2, y2, separated by a blank.

The output outputs the area on the first line when r = 1, the area on the first line when r = 2, and the perimeter on the second line. In either case, insert a line break at the end.

In 40% of the test data, the coordinates of the vertices of the rectangle are 0 or more and 100 or less, and 1/2 of them is the problem of finding only the area. Furthermore, 1/2 of the whole is the problem of finding only the area.

Input Example 1 Input Example 2 Input Example 3 Input Example 4
5 1 5 2 2 2 3 2
0 0 3 2 0 0 8 9 2 2 8 8
1 1 2 5 0 0 9 8 3 0 4 9
0 4 6 5 5 0 7 9
3 3 5 6
5 0 7 6
Output example 1 Output example 2 Output example 3 Output example 4
29 80 45
38 36

input

The input consists of multiple datasets. Input ends when both n and r are 0. The number of datasets does not exceed 10.

output

For each dataset, the area is output on the first line when r = 1, the area is output on the first line when r = 2, and the perimeter is output on the second line.

Example

Input

5 1 0 0 3 2 1 1 2 5 0 4 6 5 3 3 5 6 5 0 7 6 5 2 0 0 3 2 1 1 2 5 0 4 6 5 3 3 5 6 5 0 7 6 2 2 0 0 8 9 0 0 9 8 3 2 2 2 8 8 3 0 4 9 5 0 7 9 0 0

Output

29 29 38 80 36 45 36

inputFormat

input data. In each line after the second line, the coordinates of the lower left vertex of each sheet (x1, y1) and The coordinates of the upper right vertex coordinates (x2, y2) are written in the order of x1, y1, x2, y2, separated by a blank.

The

outputFormat

output outputs the area on the first line when r = 1, the area on the first line when r = 2, and the perimeter on the second line. In either case, insert a line break at the end.

In 40% of the test data, the coordinates of the vertices of the rectangle are 0 or more and 100 or less, and 1/2 of them is the problem of finding only the area. Furthermore, 1/2 of the whole is the problem of finding only the area.

Input Example 1 Input Example 2 Input Example 3 Input Example 4
5 1 5 2 2 2 3 2
0 0 3 2 0 0 8 9 2 2 8 8
1 1 2 5 0 0 9 8 3 0 4 9
0 4 6 5 5 0 7 9
3 3 5 6
5 0 7 6
Output example 1 Output example 2 Output example 3 Output example 4
29 80 45
38 36

input

The input consists of multiple datasets. Input ends when both n and r are 0. The number of datasets does not exceed 10.

output

For each dataset, the area is output on the first line when r = 1, the area is output on the first line when r = 2, and the perimeter is output on the second line.

Example

Input

5 1 0 0 3 2 1 1 2 5 0 4 6 5 3 3 5 6 5 0 7 6 5 2 0 0 3 2 1 1 2 5 0 4 6 5 3 3 5 6 5 0 7 6 2 2 0 0 8 9 0 0 9 8 3 2 2 2 8 8 3 0 4 9 5 0 7 9 0 0

Output

29 29 38 80 36 45 36

样例

5 1
0 0 3 2
1 1 2 5
0 4 6 5
3 3 5 6
5 0 7 6
5 2
0 0 3 2
1 1 2 5
0 4 6 5
3 3 5 6
5 0 7 6
2 2
0 0 8 9
0 0 9 8
3 2
2 2 8 8
3 0 4 9
5 0 7 9
0 0
29

29 38 80 36 45 36

</p>