Processing math: 100%
Swap - MarisaOJ: Marisa Online Judge

Swap

Time limit: 1000 ms
Memory limit: 256 MB
For an array A consisting of integers. Perform a sequence of q operations to swap two elements in array A, resulting in a new array B. Given array B, restore the original array A. ### Input - The first line contains two integers n,q. - The second line contains n integers Bi. - The next q lines each contain two indices x,y with 1≤x,y≤n, representing the operation to swap elements at positions x and y in array A. ### Output - Output n integers representing the original array A. ### Constraints - 1≤n,q,Bi≤1000. ### Example Input: 541234512243115 Output: 43521