luogu#P4743. [Wind Festival] Energy Center
[Wind Festival] Energy Center
Background
saw everyone preparing so seriously for the party, so this cute girl also became a volunteer!
Problem Description
came to the energy center of the kite festival, where everyone is preparing for the party. There are a total of devices here. Of course, due to changes in the plan, devices may be added or removed at any time. However, the total number of devices will not exceed . Keeping track of the number of devices at any time is also one of the volunteer's jobs.
Each device has some attributes. For example, for device , for each attribute it has (say attribute ), there is a given value, denoted as . But attributes are shared, which means that even if a device does not have a certain attribute, it only makes its value for that attribute equal to . The number of attributes is . Note that the attribute indices range from to .
Now the volunteers are trying to connect a consecutive segment of devices together, with the following effect:
- For devices from to , the final value of attribute is .
The volunteers need 's help, but doing the calculations is too troublesome. also hopes you can help her.
Input Format
The first line contains two integers and .
In the next lines, the first integer is , meaning device has attributes. Then there are integers, and , meaning .
Then there is an integer , meaning there are operations. Each operation is one of the following:
: Insert a device after device . The next line contains its description, the same as initialization.
: Discard the -th device.
: Query the total number of devices.
: Query the effect of connecting devices to .
The input is guaranteed to be valid.
Output Format
For each , output one integer on a single line.
For each , output integers on one line. If the value of attribute is , output at that position.
Note!
After completing all operations, please output one extra line: "end" (without the double quotes).
4 4
4 0 1 1 2 2 2 3 1
2 0 1 2 1
0
2 1 2 3 1
5
QA
I 2
2 1 1 3 2
QS 2 4
QA
QS 1 1
4
1 1 1 2
5
1 2 2 1
end
Hint
For of the testdata, .
For an additional of the testdata, , and it is guaranteed that there are no operations.
For of the testdata, .
Translated by ChatGPT 5