Josephus Transform
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Roundgod is given a permutation of length (initially ) and operations, each operation can be expressed as a pair , which means to do Josephus transform for times on permutation . Print the final permutation in one line.

Josephus transform is that: firstly list the integers in premutation in a ring, then count numbers from the first number, erase the result number from the ring and write it into the back of the new permutation , then count numbers from the next number and do the same things again, until all numbers are written into , which is the result permutation after doing Josephus transform for once on . For example, will become if we do Josephus transform for once on it.

输入描述:

The first line contains two integers .
Next lines each contains two integers , denoting one operation .

输出描述:

Print  integers, the final permutation in one line.
示例1

输入

复制
5 1
3 1

输出

复制
3 1 5 2 4
示例2

输入

复制
5 2
3 3
2 3

输出

复制
1 2 3 4 5