CF691D Swaps in Permutation
Description
You are given a permutation of the numbers $ 1,2,...,n $ and $ m $ pairs of positions $ (a_{j},b_{j}) $ .
At each step you can choose a pair from the given positions and swap the numbers in that positions. What is the lexicographically maximal permutation one can get?
Let $ p $ and $ q $ be two permutations of the numbers $ 1,2,...,n $ . $ p $ is lexicographically smaller than the $ q $ if a number $ 1
Input Format
The first line contains two integers $ n $ and $ m $ ( $ 1
Output Format
Print the only line with $ n $ distinct integers $ p'_{i} $ ( $ 1