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

2244. Runes in the Field 3

Time limit: 2.0 second
Memory limit: 256 MB
Vadim once again found himself on an infinite field, which can be represented as a plane with Cartesian coordinates. At the very center of the field, at the point O with coordinates (0; 0), he saw an ancient manuscript. When he touched it, M runes began to glow on the field with an enchanting blue light, and grass suddenly grew on N segments, which did not intersect each other. Vadim immediately understood what needed to be done, but after taking one step toward one of the runes, everything disappeared.
After carefully reading the manuscript, Vadim realized that it was enough for him to count the number of runes he could see. As is known, Vadim has a field of view of 90∘, and initially he is looking in the direction of vector s (in other words, Vadim sees everything between the directions RO−45∘ s and RO45∘ s). The grown grass blocks the view of the runes. Even if a rune lies on a segment, it is not visible. Runes do not block the view of other runes, even if they are at the same point. It takes one minute to count the runes, but in the next minute one of two events will happen:
  1. One rune teleports to another place on the field.
  2. Vadim turns to look in the direction of vector v.
Of course, after each of the events (there will be exactly Q of them) it is necessary to count the runes again. Help Vadim do this.

Input

The first line contains two integers sx and sy — the coordinates of the vector in the direction of which Vadim is initially looking.
The second line contains an integer N — the number of grass segments (1 ≤ N ≤ 105).
The next N lines describe the grass segments by four numbers ax, ay, bx, and by. The ends of each segment are different.
The next line contains an integer M — the number of runes on the field (1 ≤ M ≤ 105).
The next M lines describe the coordinates of each rune by two numbers rx and ry. The runes are numbered from 1 to M in the input order.
The next line contains an integer Q — the number of events (1 ≤ Q ≤ 105).
The next Q lines describe the events in one of the following formats:
  • T i x y — rune number i teleports to point (x; y).
  • R x y — Vadim turns to look in the direction of vector (x; y).
All coordinates are integers and their absolute values do not exceed 109.
It is guaranteed that if we denote the point (0; 0) by O and take any end of a segment P and any other end of a segment or a point where a rune may be located Q, then the ray OP is not the same as the ray OQ. Also, no input point coincides with O, and O does not lie on any of the segments.

Output

First, output the number of runes Vadim sees initially, followed by Q integers representing the number of runes Vadim sees after each event.

Sample

inputoutput
1 0
4
-4 4 0 6
2 -1 1 4
-1 2 3 -4
-2 1 -3 -2
4
-1 0
-2 3
1 -1
-1 -3
7
R 0 -1
R -2 -2
R -2 2
R 0 1
R -2 1
T 1 -3 0
T 2 -2 5
0
1
2
2
1
2
1
0
Problem Author: Vadim Barinov
Problem Source: The 2026 ICPC UrFU Qualification