#P306. 练51.3 纸杯猜数
练51.3 纸杯猜数
Description
You and Xiaohua are playing a number guessing game with paper cups.
Xiaohua has placed paper cups upside down on the table, numbered from to . Each cup has a number written inside.
Xiaohua first tells Xiaoming the numbers on each cup, then quickly performs swap operations:
Choose two cups and , and swap their positions. (If and are the same, no swap occurs)
Now Xiaohua wants you to answer: what are the numbers on the cups after operations?
Input Format
The first line contains two numbers and , representing the number of cups and operations ();
The second line contains numbers, representing the numbers inside each cup;
The next lines each contain two numbers and , indicating which cups to swap.
Output Format
Output one line containing numbers, representing the numbers inside each cup after all swaps, separated by spaces.
Sample
8 3
1 4 7 20 5 3 11 6
3 7
2 6
5 31 3 5 20 11 4 7 6
Related
In following homework: