| AGM 2023 Qualification Round |
|---|
| Finished |
Help!
On your way to the AGM(Annual Galley Meeting) you are under attack by pirates trying to destroy your ship.
The way these pirates operate is quite different from what you would usually expect: they do not shoot at you with cannons, but rather bomb entire regions of the ocean. Furthermore, the captain of the ship does not use the usual Arrr!, but rather yells Yeey! or Ooh! whenever a ship is successfully hit or not. Truly bizzare.
Luckily for you, the pirates always operate the same way, so you already know the regions that will be bombed before the trip. This way you can plan how big of a ship to embark on and what route to pick!
The region you will be passing through is a rectangular grid with $$$N$$$ rows and $$$M$$$ columns.
You know that there are $$$B$$$ axis-aligned rectangular areas inside this grid that have been bombed.
Your ship can be thought of as a sequence of consecutive cells in the same line or column of the grid.
For $$$S$$$ placements of the ship, you would like to know the state of the ship after the bombing. The state can be one of the following:
The first line contains integers $$$N$$$ and $$$M$$$, the dimensions of the grid. It is guaranteed that $$$1 \leq N, M \leq 10^5$$$.
The next line contains integer $$$B$$$, the number of bombs. It is guaranteed that $$$1 \leq B \leq 2*10^5$$$.
The next $$$B$$$ lines each contain integers $$$x1$$$, $$$y1$$$, $$$x2$$$, $$$y2$$$ describing a bombed rectangular area between cells $$$(x1, y1)$$$ and $$$(x2, y2)$$$. It is guaranteed that $$$1 \leq x_1 \leq x_2 \leq N$$$ and $$$1 \leq y_1 \leq y_2 \leq M$$$. The bombs can overlap.
The next line contains integer $$$S$$$, the number of ships whose status we would like to know. It is guaranteed that $$$1 \leq S \leq 2*10^5$$$.
Each of the next $$$S$$$ lines contains a description of a ship:
The placements of the ships can intersect each other.
The output file should contain $$$S$$$ lines, each with the state of the corresponding ship.
5 5 3 2 1 2 2 2 2 3 3 3 4 5 4 5 1 2 1 3 1 2 1 4 2 1 3 5 1 3 2 4 2 2 1 5
SUNK HIT MISS SUNK HIT
| Name |
|---|


