#K72427. Takoyaki Grill Simulator

    ID: 33751 Type: Default 1000ms 256MiB

Takoyaki Grill Simulator

Takoyaki Grill Simulator

You are given a simulation of a Takoyaki grill. The grill has dimensions H x W. Takoyaki balls are placed on the grill, and they require exactly \(T\) time units to cook.

There are three types of events:

  • 0: Place a takoyaki at position (x, y) if the cell is empty.
  • 1: Eat a takoyaki at position (x, y) if there is one and it is cooked, i.e. the takoyaki was placed at time t\(\_p\) and \(t\_p+T \leq t\) where t is the current time.
  • 2: Count the number of cooked and uncooked takoyaki in the subrectangle defined by the top-left corner (x1, y1) and the bottom-right corner (x2, y2). A takoyaki is considered cooked if its placement time + \(T\) is less than or equal to the current event time, otherwise it is uncooked.

The simulation processes \(Q\) events in the order they are given. For every event of type 2, output a line with two numbers: the number of cooked and uncooked takoyaki in the specified area.

Note: The positions are 1-indexed.

inputFormat

The first line contains four integers \(H\), \(W\), \(T\), and \(Q\), where \(H\) is the number of rows and \(W\) is the number of columns of the grill, \(T\) is the cooking time, and \(Q\) is the number of events.

The next \(Q\) lines each describe an event. Each event is given in one of the following formats:

  • For event type 0 and 1 (place and eat): t c x y
  • For event type 2 (count): t 2 x1 y1 x2 y2

\(t\) denotes the current time of the event and \(c\) denotes the event type.

outputFormat

For each event of type 2, output a single line containing two integers separated by a space: the number of cooked takoyaki and the number of uncooked takoyaki in the specified region.

## sample
3 3 3 5
1 0 1 1
2 2 1 1 2 2
4 1 1 1
5 0 2 2
6 2 1 1 3 3
0 1

0 1

</p>