AT_abc449_b [ABC449B] Deconstruct Chocolate
Description
There is a rectangular chocolate consisting of $ H $ rows and $ W $ columns of blocks.
You are given $ Q $ queries; process them in order and find the answer to each query. Each query is in one of the following formats:
- Type $ 1 $ : An integer $ R $ is given. Find the number of chocolate blocks in the bottom $ R $ rows, then eat them.
- Type $ 2 $ : An integer $ C $ is given. Find the number of chocolate blocks in the rightmost $ C $ columns, then eat them.
When the queries are processed in order, the chocolate remains rectangular after each query is processed, and it has at least $ R + 1 $ rows immediately before processing a type $ 1 $ query and has at least $ C + 1 $ columns immediately before processing a type $ 2 $ query.
Input Format
The input is given from Standard Input in the following format:
> $ H $ $ W $ $ Q\\$
> $ \text{query}_1 \\$
> $ \text{query}_2 \\$
> $ \vdots \\$
> $ \text{query}_Q $
Here, $ \text{query}_i $ is the $ i $ -th query, given in one of the following formats:
> $ 1 $ $ R $
> $ 2 $ $ C $
Output Format
Output $ Q $ lines. The $ i $ -th line $ (1 \leq i \leq Q) $ should contain the answer to the $ i $ -th query.
Explanation/Hint
### Sample Explanation 1
Initially, the chocolate is a rectangle with $ 7 $ rows and $ 9 $ columns.
For the first query, the number of chocolate blocks in the rightmost $ 4 $ columns is $ 28 $ , so output $ 28 $ . The chocolate becomes $ 7 $ rows and $ 5 $ columns.
For the second query, the number of chocolate blocks in the bottom $ 3 $ rows is $ 15 $ , so output $ 15 $ . The chocolate becomes $ 4 $ rows and $ 5 $ columns.
For the third query, the number of chocolate blocks in the rightmost $ 1 $ column is $ 4 $ , so output $ 4 $ . The chocolate becomes $ 4 $ rows and $ 4 $ columns.
For the fourth query, the number of chocolate blocks in the rightmost $ 1 $ column is $ 4 $ , so output $ 4 $ . The chocolate becomes $ 4 $ rows and $ 3 $ columns.
For the fifth query, the number of chocolate blocks in the bottom $ 3 $ rows is $ 9 $ , so output $ 9 $ . The chocolate becomes $ 1 $ row and $ 3 $ columns.
### Constraints
- $ 2 \leq H, W \leq 100 $
- $ 1 \leq Q \leq 100 $
- For type $ 1 $ queries, $ 1 \leq R $ .
- When the queries are processed in order, the chocolate has at least $ R + 1 $ rows immediately before processing a type $ 1 $ query.
- For type $ 2 $ queries, $ 1 \leq C $ .
- When the queries are processed in order, the chocolate has at least $ C + 1 $ columns immediately before processing a type $ 2 $ query.
- All input values are integers.