VATRAXIA
Problem
The FrogLab at NTUA constructs genetically modified frogs for rescue missions in lakes. To guide the rescue frogs to the rescue point, lily pads of different elasticity are placed in a row. Specifically, there are arranged lily pads and the -th one has elasticity . If a frog is placed on lily pad , it will make a jump of length and land on lily pad . It will then make a jump of length and land on lily pad , and so on. When exceeds , we consider that the frog has passed the sequence of lily pads and reached the rescue point.
The lab's testing team is interested in experimentally evaluating the effectiveness of the modified frogs. For this purpose, they conduct a series of experiments, each of which can be in one of the following two forms:
In form , the scientists replace the lily pad at position with another one of elasticity , i.e., they set .
In form , they release a frog on lily pad and count the number of jumps it makes until it reaches the rescue point, as well as the lily pad from which the last jump was made.
The lab's testing team assigns you the task of simulating this process. Specifically, you are given the initial elasticities for the lily pads as well as the experiments to be performed. Your goal is to successfully execute all experiments, and for each experiment of form , to print the last lily pad the frog passes through and the total number of jumps it makes.
Input:
In the first line of the input, there will be a positive integer , the number of test cases. In each of the next test cases, the first line will contain two non-negative integers and : the number of lily pads and the number of experiments to be performed. The second line contains positive integers , , , that indicate the initial elasticities for the lily pads. Finally, the next lines of the input each contain one experiment, in one of the forms mentioned above.
Output:
The output should contain as many lines as there are type experiments in total. Each line will contain two numbers indicating the lily pad from which the last jump was made and the number of jumps until the frog in the corresponding type experiment reaches the rescue point.
Constraints
- The total sum of all will not exceed . Similarly for Q.
- At any given time, for each .
- Time Limit: sec.
- Memory Limit: MB.
Example of Input - Output Files:
STDIN (vatraxia.in)
1
8 5
1 1 1 1 1 2 8 2
1 1
0 1 3
1 1
0 3 4
1 2
STDOUT (vatraxia.out)
8 7
8 5
7 3
Explanation of the example
In the first and only test case of the example, there are lily pads with initial elasticities as shown in the line. There are experiments.
- In the experiment, we release a frog on lily pad . This frog follows the path (, , , , , , ) before reaching the rescue point. Therefore, the output line contains , which is the last lily pad it passes, and , which is the number of jumps it made.
- In the experiment (which is of type ), we change the elasticity of lily pad to the value .
- In the experiment, we release another frog on lily pad . This time, lily pad has an elasticity of instead of , so the path the frog follows is (, , , , ). Again, the last lily pad is , but now it took jumps. Therefore, we print in the second output line.
- In the experiment, we change the elasticity of lily pad to the value .
- In the experiment, we release a frog on lily pad . It follows the path (, , ), so it takes jumps, and the last lily pad it passes is . Therefore, we print in the last output line.
Notes
- For test cases with a total value of , it will be , , and the total sum of in each test file will not exceed . The same applies to .
- For test cases with a total value of , the initial constraints will hold, and additionally, there will only be type experiments in the input.
Comments