#CCBCHBAHAI0000100. Bản sao độc lập: sửa B không làm đổi A
Bản sao độc lập: sửa B không làm đổi A
Independent Copy: Mutating B Does Not Change A
Source: Phuoc Hung OJ
Version: Phuoc Hung OJ Extended
Problem
Given , first create an independent copy with for every valid index. Then process updates on only, each performing . All indices are valid and the same position may be updated more than once. Array must remain unchanged.
Input
The first line contains . The second line contains . Each of the next lines contains with .
Output
Print the unchanged on the first line and final on the second line.
Subtask
Subtask 1 (20 points): , .
Subtask 2 (30 points): , .
Subtask 3 (50 points): , .
Example
Input
4 3
5 6 7 8
1 10
3 -2
1 99
Output
5 6 7 8
5 99 7 -2
Explanation
Only the independent copy is updated; the source array remains unchanged.