Counting Fish Again
题号:NC239620
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 512 M,其他语言1024 M
Special Judge, 64bit IO Format: %lld

题目描述

See Problem N for PDF statements.
Many years later, as he faced the Nowcoder Multi-University Training Contest, ACMer NIO was to remember that distant afternoon when his coach took him to count fish.

In a famous fish-counting problem in 2019, OIer NIO was asked to count the number of fish in 2D space. Unfortunately, the characteristics of fish were too complex, making counting them an almost impossible task. So let's look at this simplified fish-counting problem.

In this problem, NIO is given an infinite grid graph. And the god of fish will perform m operations on it. Assuming the coordinates of the bottom left corner of the grid graph are (0,0), there are two types of operations:
  • : Draw a segment between (x_1,y_1) and (x_2,y_2). It is guaranteed that , and the drawn segments do not overlap with the existing ones.
  • : Erase a segment between (x_1,y_1) and (x_2,y_2). Still, , and the segment alrealy exists in the grid graph.
After each operation, NIO needs to calculate the number of fish in this grid. In this problem, a fish is defined as a shape that satisfies the following rules.
  • It consists of a square and an equilateral right triangle, and the triangle's right-angle vertex coincides with one vertex of the square.
  • The length of the right-angle side of the triangle is equal to the square's side length.


Note that the original segments of the grid graph can also be part of a fish.

输入描述:

The first line contains a single integer m (), indicating the number of operations.

Each of the next m lines contains five integers op,x_1,y_1,x_2,y_2 (, , , ), indicating the operation and the segment between (x_1,y_1) and (x_2,y_2).

输出描述:

For each query, output an integer in a single line indicating the number of fish in the graph.
示例1

输入

复制
3
1 0 4 2 2
1 2 2 4 0
2 1 3 4 0

输出

复制
4
12
1

说明

Here is the explanation of the example.

First, the god of fish draws a segment between (0,4) and (2,2).

As highlighted in the picture, there are 4 fish in the graph.



Then, the god of fish draws a segment between (2,2) and (4,0).

As highlighted in the picture, there are 8 new fish in the graph, so there are 12 fish in total.



Finally, the god of fish erases the segment between (1,3) and (4,0).

As highlighted in the picture, there is only 1 fish left in the graph.