Permutation Transformer

Write a program to transform the permutation 1, 2, 3, . . . , n according to m instructions. Each instruc- tion (a, b) means to take out the subsequence from the a-th to the b-th element, reverse it, then append it to the end. Input There is only one case for this problem. The first line contains two integers n and m (1 ≤ n,m ≤ 100, 000). Each of the next m lines contains an instruction consisting of two integers a and b (1 ≤ a ≤ b ≤ n). Output Print n lines, one for each integer, the final permutation. Explanation of the sample below Instruction (2,5): Take out the subsequence {2,3,4,5}, reverse it to {5,4,3,2}, append it to the remaining permutation {1,6,7,8,9,10} Instruction (4,8): The subsequence from the 4-th to the 8-th element of {1,6,7,8,9,10,5,4,3,2} is {8,9,10,5,4}. Take it out, reverse it, and you’ll get the sample output. Sample Input 10 2 25 48 Sample Output 1 6 7 3 2 4 5 10 9 8