13438 - Lucky money 1   

Description

Receiving lucky money is the favorite activity of children during Chinese New Year.

Denny's family has N children, everyone wants to get the lucky money as soon as possible.

The elders in the family have prepared a game to decide the order of receiving the lucky money:

  • At the beginning, all children line up from left to right and numbered sequentially
  • Randomly decide two number A and K, move the child at position A to the right by K positions, If he  can't move K positions to the right, move to the far right.

For example:

N = 6, The initial order: 1 2 3 4 5 6

A = 3, K = 2, The new order: 1 2 4 5 3 6

A = 1, K = 3, The new order: 2 4 5 1 3 6

A = 5, K = 3, The new order: 2 4 5 1 6 3

Input

The first line contains two integer N M, the number of children and the number of times of changing positions

Each of he following M line contains two integer A K.

test cases:

(6/6) 1 <= A <= N, M, K <= 100

Output

The output contains N + 1 lines, the initial order and new order after changing position.

Sample Input  Download

Sample Output  Download

Partial Judge Code

13438.c

Partial Judge Header

13438.h

Tags




Discuss