Counting-out Rhyme

题意翻译

n 个孩子在玩一个游戏。 孩子们站成一圈,按照顺时针顺序分别被标号为 1 到 n。开始游戏时,第一个孩子成为领导。 游戏进行 k 轮。 在第 i 轮中,领导会从他顺时针方向下一个孩子开始数 ai 个孩子。最后数到的那个孩子出局,再下一个孩子成为新的领导。 举个例子, 现在圈内还剩 [8, 10, 13, 14, 16]5个孩子,领导编号为 13 , ai = 12。那么出局的孩子为 16 。第 8 个孩子成为下一个领导。 你需要写一个代码模拟这个过程,求出每轮比赛出局的孩子。 第一行包含两个整数 n 和 k (2 ≤ n ≤ 100, 1 ≤ k ≤ n - 1). 第二行包含 k 个整数 a1, a2, ..., ak (1 ≤ ai ≤ 109). 输出 k 个整数,第 i 个整数表示第 i轮出局的孩子。

题目描述

$ n $ children are standing in a circle and playing the counting-out game. Children are numbered clockwise from $ 1 $ to $ n $ . In the beginning, the first child is considered the leader. The game is played in $ k $ steps. In the $ i $ -th step the leader counts out $ a_{i} $ people in clockwise order, starting from the next person. The last one to be pointed at by the leader is eliminated, and the next player after him becomes the new leader. For example, if there are children with numbers $ [8,10,13,14,16] $ currently in the circle, the leader is child $ 13 $ and $ a_{i}=12 $ , then counting-out rhyme ends on child $ 16 $ , who is eliminated. Child $ 8 $ becomes the leader. You have to write a program which prints the number of the child to be eliminated on every step.

输入输出格式

输入格式


The first line contains two integer numbers $ n $ and $ k $ ( $ 2<=n<=100 $ , $ 1<=k<=n-1 $ ). The next line contains $ k $ integer numbers $ a_{1},a_{2},...,a_{k} $ ( $ 1<=a_{i}<=10^{9} $ ).

输出格式


Print $ k $ numbers, the $ i $ -th one corresponds to the number of child to be eliminated at the $ i $ -th step.

输入输出样例

输入样例 #1

7 5
10 4 11 4 1

输出样例 #1

4 2 5 6 1 

输入样例 #2

3 2
2 5

输出样例 #2

3 2 

说明

Let's consider first example: - In the first step child $ 4 $ is eliminated, child $ 5 $ becomes the leader. - In the second step child $ 2 $ is eliminated, child $ 3 $ becomes the leader. - In the third step child $ 5 $ is eliminated, child $ 6 $ becomes the leader. - In the fourth step child $ 6 $ is eliminated, child $ 7 $ becomes the leader. - In the final step child $ 1 $ is eliminated, child $ 3 $ becomes the leader.