# ДОРЕШИВАНИЕ 2014 ACM-ICPC Украина, 2ой Раунд Украина, Сентябрь 13

# Counting-Out

**n** children, standing in a circle, are using counting-outs to determine who will leave the circle. It means, they recite counting-out rhymes, pointing each rhyme’s word on next (by circle) child. The child being pointed on at the last word of the rhyme leaves the circle.

The process repeats **k** (**1** ≤ **k** ≤ **n**) times, restarting from the child following the one who just had left the circle. Counting starts from lower numbers to higher, but counting-out rhymes are different.

Write a program which reads number of children, number of counting-out rhymes, and numbers of words in used counting-out rhymes, and finds the order in which children will leave the circle.

** Input**

The first line contains space separated number of children **n** (**1** ≤ **n** ≤ **10 ^{18}**) and number of used counting-out rhymes

**k**(

**1**≤

**k**≤ min(

**n**,

**10**)). The second line contains

^{5}**k**integers (each in range

**1**≤

**a**≤

_{i}**10**) - numbers of words in the counting-out rhymes, used the

^{18}**1**st, the

**2**nd, …, the

**k**-th time.

** Output**

The only line of the output should contain space-separated sequence of **k** numbers - the numbers of the children leaving the circle after the corresponding counting-out. Initially, children are numbered from **1** to **k**, and the **1**st is the child who is pointed on when reciting the **1**st word of the **1**st counting-out rhyme. Further, each child keeps the same number, irrespectively of how children leave the circle.

10 5 2 7 1 8 2

2 9 10 1 4

8 3 10 1 2

2 3 5