Quadrant Queries#5494

Quadrant Queries

3 seconds
64 megabytes
Medium

There are points in the plane. The -th point has coordinates (x_i, y_i). You need to process the following types of queries, where each query specifies the indices of the boundary points ( and ), and includes both endpoints:

Reflect all points from point to point (inclusive) about the axis. This query is given as X i j.

Reflect all points from point to point (inclusive) about the axis. This query is given as Y i j.

Count how many points from point to point (inclusive) lie in each of the four quadrants. This query is given as C i j.

Input

The first line contains an integer (1 \le n \le 100000), the number of points. The following lines each contain two integers x_i and y_i, separated by a space. The next line contains an integer (1 \le q \le 1000000), the number of queries. Each of the next lines contains one query in one of the forms described above. All indices are -based. You are guaranteed that no point lies on the or axes. All coordinates (x_i, y_i) fit into a -bit signed integer.

Output

For each query of the type C i j (1 \le i \le j \le n), print one line containing four integers — the number of points with indices in the range that are in the st, nd, rd, and th quadrants, respectively.

Examples

Example 1

Loading
Loading