Inaho is finally home! After being stuck in an -dimensional for so long, he has started to comprehend the complexities of dimensions and have thought of a problem. Unfortunately, he does not know of a solution as he is not yet a master of dimensions, so he has asked you for help.
Given an -dimensional array, and a type of operation:
Type operation: print the normal array given the Binary Indexed Tree.
Type operation: print the Binary Indexed Tree given the normal array.
Input Specification
The first line will contain two space-separated integers , and , the number of dimensions and the type of operation respectively.
The second line will contain space-separated integers , which are the values in the array. If , this array is the Binary Indexed Tree, and if , this array is the normal array.
represents the value at position where .
In other words, the second line will be a flattened -dimensional grid.
Output Specification
The normal array, if the , or the Binary Indexed Tree, if .
The output should follow the same format as the second line of the input. That is, the integer should represent the value at where .
Subtasks
Subtask 1 [10%]
Subtask 2 [20%]
Subtask 3 [20%]
Subtask 4 [50%]
No further constraints.
Sample Cases Note
For the sake of not having 10 million characters in the sample cases and for the sample cases to be useful, . In the actual test cases, however, will follow the constraints as stated in the Input Specification (that is, ).
Sample Input 1
1 1
1 2 1 4 1 2 1 8 1 2 1 4 1 2 1 16 1 2 1 4
Sample Output 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Sample Input 2
2 2
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Sample Output 2
1 2 1 4 2 4 2 8 1 2 1 4 4 8 4 16
Sample Input 3
4 1
1 9 3 2 4 7 5 8 2 9 1 8 4 9 2 10
Sample Output 3
1 8 2 -9 3 -5 -1 9 1 -1 -3 9 -1 3 0 -6
Comments