ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

2215. Global Changes

Time limit: 3.0 second
Memory limit: 256 MB
The planet Kirazuv began to change significantly at the beginning of this week. This planet has N cities, whose coordinates before the changes started were (xi, yi). Now, at any moment, a huge pillar can emerge from the ground and rotate all the cities around itself by 90, 180, or 270 counterclockwise. However, the most dangerous aspect of this situation is the radioactive rains. They can occur at any time, and their effects are felt in the cities within the rectangle ((x1, y1), (x2, y1), (x2, y2), (x1, y2)).
Before the start of these global changes, scientists on the planet Kirazuv launched a meteorological satellite over (0, 0), which can analyze both of these events. Note that the rotations of the planet do not move this satellite. Now, you have a description of Q different events, and you need to count for each rain how many cities felt its effects.

Input

The first line contains an integer N — the number of cities on the planet Kirazuv (1 ≤ N ≤ 4 · 104).
The following N lines describe the coordinates of the cities before the changes with two integers xi and yi. It is guaranteed that no two cities have the same coordinates.
The next line contains an integer Q — the number of events that occurred on the planet (1 ≤ Q ≤ 4 · 104).
The following Q lines describe the events in the order they occurred in one of the following formats:
  • r90 x y — a pillar appears at point (x, y) and rotates all cities by 90 counterclockwise;
  • r180 x y — a pillar appears at point (x, y) and rotates all cities by 180 counterclockwise;
  • r270 x y — a pillar appears at point (x, y) and rotates all cities by 270 counterclockwise;
  • ask x1 y1 x2 y2 — a radioactive rain affects all cities in the rectangle ((x1, y1), (x2, y1), (x2, y2), (x1, y2)), and you need to answer how many cities are affected by this rain (x1 ≤ x2, y1 ≤ y2).
All coordinates in the input data are integers and do not exceed 109 in absolute value.

Output

For each radioactive rain, output the number of cities that it affected.

Sample

inputoutput
4
1 1
2 2
3 3
4 4
4
r90 0 0
ask -2 -1 0 4
r180 1 1
ask 3 -3 6 0
2
3

Notes

In this example, after the first rotation, the coordinates of the cities will be (−1, 1), (−2, 2), (−3, 3), and (−4, 4) respectively.
After the second rotation, they will be (3, 1), (4, 0), (5, −1), and (6, −2).
Problem Author: Vadim Barinov
Problem Source: University academic school olympiad in informatics 2024