#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 A=(a0,…,an−1)A=(a_0,\ldots,a_{n-1}), first create an independent copy BB with bi=aib_i=a_i for every valid index. Then process qq updates (p,x)(p,x) on BB only, each performing bp←xb_p\leftarrow x. All indices are valid and the same position may be updated more than once. Array AA must remain unchanged.

Input

The first line contains n,qn,q. The second line contains AA. Each of the next qq lines contains p,xp,x with 0≤p<n0\le p<n.

Output

Print the unchanged AA on the first line and final BB on the second line.

Subtask

Subtask 1 (20 points): 1≤n≤101\le n\le10, 0≤q≤100\le q\le10.

Subtask 2 (30 points): 1≤n≤1001\le n\le100, 0≤q≤1000\le q\le100.

Subtask 3 (50 points): 1≤n≤10001\le n\le1000, 0≤q≤10000\le q\le1000.

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.